mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 05:53:59 +00:00
global_safety: port RelaxedAtomicBool
This commit is contained in:
parent
a0eed3760e
commit
76145145fd
1 changed files with 18 additions and 0 deletions
18
fish-rust/src/global_safety.rs
Normal file
18
fish-rust/src/global_safety.rs
Normal 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)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue