tokio/loom/std/
atomic_u32.rs1use std::cell::UnsafeCell;
2use std::fmt;
3use std::ops::Deref;
4use std::panic;
5
6pub(crate) struct AtomicU32 {
8 inner: UnsafeCell<std::sync::atomic::AtomicU32>,
9}
10
11unsafe impl Send for AtomicU32 {}
12unsafe impl Sync for AtomicU32 {}
13impl panic::RefUnwindSafe for AtomicU32 {}
14impl panic::UnwindSafe for AtomicU32 {}
15
16impl AtomicU32 {
17 pub(crate) const fn new(val: u32) -> AtomicU32 {
18 let inner = UnsafeCell::new(std::sync::atomic::AtomicU32::new(val));
19 AtomicU32 { inner }
20 }
21
22 pub(crate) unsafe fn unsync_load(&self) -> u32 {
29 self.load(std::sync::atomic::Ordering::Relaxed)
31 }
32}
33
34impl Deref for AtomicU32 {
35 type Target = std::sync::atomic::AtomicU32;
36
37 fn deref(&self) -> &Self::Target {
38 unsafe { &*self.inner.get() }
41 }
42}
43
44impl fmt::Debug for AtomicU32 {
45 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
46 self.deref().fmt(fmt)
47 }
48}