/// Performs an unsynchronized load. /// /// # Safety /// /// All mutations must have happened before the unsynchronized load. /// Additionally, there must be no concurrent mutations. pub(crate) unsafefn unsync_load(&self) -> usize { // See <https://github.com/tokio-rs/tokio/issues/6155> self.load(std::sync::atomic::Ordering::Relaxed)
}
pub(crate) fn with_mut<R>(&mutself, f: impl FnOnce(&mut usize) -> R) -> R { // safety: we have mutable access
f(unsafe { (*self.inner.get()).get_mut() })
}
}
impl ops::Deref for AtomicUsize { type Target = std::sync::atomic::AtomicUsize;
fn deref(&self) -> &Self::Target { // safety: it is always safe to access `&self` fns on the inner value as // we never perform unsafe mutations. unsafe { &*self.inner.get() }
}
}
impl ops::DerefMut for AtomicUsize { fn deref_mut(&mutself) -> &mutSelf::Target { // safety: we hold `&mut self` unsafe { &mut *self.inner.get() }
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.