mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
rt: change AtomicNotified back to AcqRel (#8120)
In #7431, I originally implemented `AtomicNotified` with the `AcqRel` atomic ordering, which is all that *should* be necessary here. While trying to debug a failing test on ARM, I changed it to `SeqCst`. This fixed the test, but was not actually necessary to solve the root cause of that test failure, which was ultimately fixed in #8008 instead. Using `SeqCst` here and locking the bus probably increases the overhead of using the LIFO slot substantially, so I've un-done that.
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::runtime::task::{Header, Notified, RawTask};
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::sync::atomic::Ordering::SeqCst;
|
use std::sync::atomic::Ordering::{AcqRel, Acquire};
|
||||||
|
|
||||||
/// An atomic cell which can contain a pointer to a [`Notified`] task.
|
/// An atomic cell which can contain a pointer to a [`Notified`] task.
|
||||||
///
|
///
|
||||||
@@ -29,7 +29,7 @@ impl<S: 'static> AtomicNotified<S> {
|
|||||||
let new = task
|
let new = task
|
||||||
.map(|t| t.into_raw().header_ptr().as_ptr())
|
.map(|t| t.into_raw().header_ptr().as_ptr())
|
||||||
.unwrap_or_else(ptr::null_mut);
|
.unwrap_or_else(ptr::null_mut);
|
||||||
let old = self.task.swap(new, SeqCst);
|
let old = self.task.swap(new, AcqRel);
|
||||||
NonNull::new(old).map(|ptr| unsafe {
|
NonNull::new(old).map(|ptr| unsafe {
|
||||||
// Safety: since we only allow tasks with the same scheduler type to
|
// Safety: since we only allow tasks with the same scheduler type to
|
||||||
// be placed in this cell, we know that the pointed task's scheduler
|
// be placed in this cell, we know that the pointed task's scheduler
|
||||||
@@ -43,7 +43,7 @@ impl<S: 'static> AtomicNotified<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn is_some(&self) -> bool {
|
pub(crate) fn is_some(&self) -> bool {
|
||||||
!self.task.load(SeqCst).is_null()
|
!self.task.load(Acquire).is_null()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user