chore: use relaxed load for unsync_load (#6203)

This commit is contained in:
Alice Ryhl
2023-12-08 22:28:40 +00:00
committed by GitHub
parent c9273f1aee
commit 1968565825
3 changed files with 3 additions and 12 deletions
+1 -4
View File
@@ -24,10 +24,7 @@ impl AtomicU16 {
/// Additionally, there must be no concurrent mutations.
pub(crate) unsafe fn unsync_load(&self) -> u16 {
// See <https://github.com/tokio-rs/tokio/issues/6155>
#[cfg(miri)]
return self.load(std::sync::atomic::Ordering::Relaxed);
#[cfg(not(miri))]
return core::ptr::read(self.inner.get() as *const u16);
self.load(std::sync::atomic::Ordering::Relaxed)
}
}
+1 -4
View File
@@ -24,10 +24,7 @@ impl AtomicU32 {
/// Additionally, there must be no concurrent mutations.
pub(crate) unsafe fn unsync_load(&self) -> u32 {
// See <https://github.com/tokio-rs/tokio/issues/6155>
#[cfg(miri)]
return self.load(std::sync::atomic::Ordering::Relaxed);
#[cfg(not(miri))]
return core::ptr::read(self.inner.get() as *const u32);
self.load(std::sync::atomic::Ordering::Relaxed)
}
}
+1 -4
View File
@@ -24,10 +24,7 @@ impl AtomicUsize {
/// Additionally, there must be no concurrent mutations.
pub(crate) unsafe fn unsync_load(&self) -> usize {
// See <https://github.com/tokio-rs/tokio/issues/6155>
#[cfg(miri)]
return self.load(std::sync::atomic::Ordering::Relaxed);
#[cfg(not(miri))]
return core::ptr::read(self.inner.get() as *const usize);
self.load(std::sync::atomic::Ordering::Relaxed)
}
pub(crate) fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R {