Struct loom::sync::atomic::AtomicBool
source · pub struct AtomicBool(/* private fields */);
Expand description
Mock implementation of std::sync::atomic::AtomicBool
.
NOTE: Unlike std::sync::atomic::AtomicBool
, this type has a different
in-memory representation than bool
.
Implementations§
source§impl AtomicBool
impl AtomicBool
sourcepub fn new(v: bool) -> AtomicBool
pub fn new(v: bool) -> AtomicBool
Creates a new instance of AtomicBool
.
sourcepub unsafe fn unsync_load(&self) -> bool
pub unsafe fn unsync_load(&self) -> bool
Load the value without any synchronization.
§Safety
An unsynchronized atomic load technically always has undefined behavior.
However, if the atomic value is not currently visible by other threads,
this should always be equivalent to a non-atomic load of an un-shared
bool
value.
sourcepub fn into_inner(self) -> bool
pub fn into_inner(self) -> bool
Consumes the atomic and returns the contained value.
sourcepub fn swap(&self, val: bool, order: Ordering) -> bool
pub fn swap(&self, val: bool, order: Ordering) -> bool
Stores a value into the atomic bool, returning the previous value.
sourcepub fn compare_and_swap(
&self,
current: bool,
new: bool,
order: Ordering
) -> bool
pub fn compare_and_swap( &self, current: bool, new: bool, order: Ordering ) -> bool
Stores a value into the atomic bool if the current value is the same as the current
value.
sourcepub fn compare_exchange(
&self,
current: bool,
new: bool,
success: Ordering,
failure: Ordering
) -> Result<bool, bool>
pub fn compare_exchange( &self, current: bool, new: bool, success: Ordering, failure: Ordering ) -> Result<bool, bool>
Stores a value into the atomic if the current value is the same as the current
value.
sourcepub fn compare_exchange_weak(
&self,
current: bool,
new: bool,
success: Ordering,
failure: Ordering
) -> Result<bool, bool>
pub fn compare_exchange_weak( &self, current: bool, new: bool, success: Ordering, failure: Ordering ) -> Result<bool, bool>
Stores a value into the atomic if the current value is the same as the current value.
sourcepub fn fetch_and(&self, val: bool, order: Ordering) -> bool
pub fn fetch_and(&self, val: bool, order: Ordering) -> bool
Logical “and” with the current value.
sourcepub fn fetch_nand(&self, val: bool, order: Ordering) -> bool
pub fn fetch_nand(&self, val: bool, order: Ordering) -> bool
Logical “nand” with the current value.
sourcepub fn fetch_or(&self, val: bool, order: Ordering) -> bool
pub fn fetch_or(&self, val: bool, order: Ordering) -> bool
Logical “or” with the current value.
sourcepub fn fetch_xor(&self, val: bool, order: Ordering) -> bool
pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool
Logical “xor” with the current value.