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