Skip to content

Commit 1968565

Browse files
authored
chore: use relaxed load for unsync_load (#6203)
1 parent c9273f1 commit 1968565

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

tokio/src/loom/std/atomic_u16.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ impl AtomicU16 {
2424
/// Additionally, there must be no concurrent mutations.
2525
pub(crate) unsafe fn unsync_load(&self) -> u16 {
2626
// See <https://github.com/tokio-rs/tokio/issues/6155>
27-
#[cfg(miri)]
28-
return self.load(std::sync::atomic::Ordering::Relaxed);
29-
#[cfg(not(miri))]
30-
return core::ptr::read(self.inner.get() as *const u16);
27+
self.load(std::sync::atomic::Ordering::Relaxed)
3128
}
3229
}
3330

tokio/src/loom/std/atomic_u32.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ impl AtomicU32 {
2424
/// Additionally, there must be no concurrent mutations.
2525
pub(crate) unsafe fn unsync_load(&self) -> u32 {
2626
// See <https://github.com/tokio-rs/tokio/issues/6155>
27-
#[cfg(miri)]
28-
return self.load(std::sync::atomic::Ordering::Relaxed);
29-
#[cfg(not(miri))]
30-
return core::ptr::read(self.inner.get() as *const u32);
27+
self.load(std::sync::atomic::Ordering::Relaxed)
3128
}
3229
}
3330

tokio/src/loom/std/atomic_usize.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ impl AtomicUsize {
2424
/// Additionally, there must be no concurrent mutations.
2525
pub(crate) unsafe fn unsync_load(&self) -> usize {
2626
// See <https://github.com/tokio-rs/tokio/issues/6155>
27-
#[cfg(miri)]
28-
return self.load(std::sync::atomic::Ordering::Relaxed);
29-
#[cfg(not(miri))]
30-
return core::ptr::read(self.inner.get() as *const usize);
27+
self.load(std::sync::atomic::Ordering::Relaxed)
3128
}
3229

3330
pub(crate) fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R {

0 commit comments

Comments
 (0)