global_safety: port RelaxedAtomicBool

This commit is contained in:
Johannes Altmanninger 2023-03-26 17:23:05 +02:00
parent a0eed3760e
commit 76145145fd

View file

@ -0,0 +1,18 @@
use std::sync::atomic::{AtomicBool, Ordering};
pub struct RelaxedAtomicBool(AtomicBool);
impl RelaxedAtomicBool {
pub const fn new(value: bool) -> Self {
Self(AtomicBool::new(value))
}
pub fn load(&self) -> bool {
self.0.load(Ordering::Relaxed)
}
pub fn store(&self, value: bool) {
self.0.store(value, Ordering::Relaxed)
}
pub fn swap(&self, value: bool) -> bool {
self.0.swap(value, Ordering::Relaxed)
}
}