mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
runtime: fix unsync_load
on atomic types (#5175)
This commit is contained in:
parent
a1002a2203
commit
9884fe3394
@ -23,7 +23,7 @@ impl AtomicU16 {
|
||||
/// All mutations must have happened before the unsynchronized load.
|
||||
/// Additionally, there must be no concurrent mutations.
|
||||
pub(crate) unsafe fn unsync_load(&self) -> u16 {
|
||||
*(*self.inner.get()).get_mut()
|
||||
core::ptr::read(self.inner.get() as *const u16)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ impl AtomicU32 {
|
||||
/// All mutations must have happened before the unsynchronized load.
|
||||
/// Additionally, there must be no concurrent mutations.
|
||||
pub(crate) unsafe fn unsync_load(&self) -> u32 {
|
||||
*(*self.inner.get()).get_mut()
|
||||
core::ptr::read(self.inner.get() as *const u32)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ impl AtomicUsize {
|
||||
/// All mutations must have happened before the unsynchronized load.
|
||||
/// Additionally, there must be no concurrent mutations.
|
||||
pub(crate) unsafe fn unsync_load(&self) -> usize {
|
||||
*(*self.inner.get()).get_mut()
|
||||
core::ptr::read(self.inner.get() as *const usize)
|
||||
}
|
||||
|
||||
pub(crate) fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R {
|
||||
|
@ -111,7 +111,7 @@ const fn normal_or_miri(normal: usize, miri: usize) -> usize {
|
||||
|
||||
#[test]
|
||||
fn stress1() {
|
||||
const NUM_ITER: usize = 1;
|
||||
const NUM_ITER: usize = 5;
|
||||
const NUM_STEAL: usize = normal_or_miri(1_000, 10);
|
||||
const NUM_LOCAL: usize = normal_or_miri(1_000, 10);
|
||||
const NUM_PUSH: usize = normal_or_miri(500, 10);
|
||||
|
Loading…
x
Reference in New Issue
Block a user