Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use relaxed load for unsync_load 2 #6203

Merged
merged 1 commit into from Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions tokio/src/loom/std/atomic_u16.rs
Expand Up @@ -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)
}
}

Expand Down
5 changes: 1 addition & 4 deletions tokio/src/loom/std/atomic_u32.rs
Expand Up @@ -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)
}
}

Expand Down
5 changes: 1 addition & 4 deletions tokio/src/loom/std/atomic_usize.rs
Expand Up @@ -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 {
Expand Down