pub struct AtomicExecutorStatus(/* private fields */);
Expand description
A wrapper around ExecutorStatus
which can be safely shared between threads.
This type uses an AtomicUsize
to store the enum value.
Implementations§
Source§impl AtomicExecutorStatus
impl AtomicExecutorStatus
Sourcepub const fn new(v: ExecutorStatus) -> AtomicExecutorStatus
pub const fn new(v: ExecutorStatus) -> AtomicExecutorStatus
Creates a new atomic ExecutorStatus
.
Sourcepub fn into_inner(self) -> ExecutorStatus
pub fn into_inner(self) -> ExecutorStatus
Consumes the atomic and returns the contained value.
This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.
Sourcepub fn set(&mut self, v: ExecutorStatus)
pub fn set(&mut self, v: ExecutorStatus)
Sets the value of the atomic without performing an atomic operation.
This is safe because the mutable reference guarantees that no other threads are concurrently accessing the atomic data.
Sourcepub fn get(&mut self) -> ExecutorStatus
pub fn get(&mut self) -> ExecutorStatus
Gets the value of the atomic without performing an atomic operation.
This is safe because the mutable reference guarantees that no other threads are concurrently accessing the atomic data.
Sourcepub fn swap_mut(&mut self, v: ExecutorStatus) -> ExecutorStatus
pub fn swap_mut(&mut self, v: ExecutorStatus) -> ExecutorStatus
Stores a value into the atomic, returning the previous value, without performing an atomic operation.
This is safe because the mutable reference guarantees that no other threads are concurrently accessing the atomic data.
Sourcepub fn load(&self, order: Ordering) -> ExecutorStatus
pub fn load(&self, order: Ordering) -> ExecutorStatus
Loads a value from the atomic.
load
takes an Ordering
argument which describes the memory ordering of this operation. Possible values are SeqCst
, Acquire
and Relaxed
.
§Panics
Panics if order is Release
or AcqRel
.
Sourcepub fn store(&self, val: ExecutorStatus, order: Ordering)
pub fn store(&self, val: ExecutorStatus, order: Ordering)
Stores a value into the atomic.
store
takes an Ordering
argument which describes the memory ordering of this operation. Possible values are SeqCst
, Release
and Relaxed
.
§Panics
Panics if order is Acquire
or AcqRel
.
Source§impl AtomicExecutorStatus
impl AtomicExecutorStatus
Sourcepub fn swap(&self, val: ExecutorStatus, order: Ordering) -> ExecutorStatus
pub fn swap(&self, val: ExecutorStatus, order: Ordering) -> ExecutorStatus
Stores a value into the atomic, returning the previous value.
swap
takes an Ordering
argument which describes the memory ordering of this operation.
All ordering modes are possible. Note that using Acquire
makes the store part of this operation Relaxed
,
and using Release
makes the load part Relaxed
.
Sourcepub fn compare_and_swap(
&self,
current: ExecutorStatus,
new: ExecutorStatus,
order: Ordering,
) -> ExecutorStatus
👎Deprecated: Use compare_exchange
or compare_exchange_weak
instead
pub fn compare_and_swap( &self, current: ExecutorStatus, new: ExecutorStatus, order: Ordering, ) -> ExecutorStatus
compare_exchange
or compare_exchange_weak
insteadStores a value into the atomic if the current value is the same as the current
value.
The return value is always the previous value. If it is equal to current
, then the value was updated.
compare_and_swap
also takes an Ordering
argument which describes the memory ordering of this operation.
Notice that even when using AcqRel
, the operation might fail and hence just perform an Acquire
load, but
not have Release
semantics. Using Acquire
makes the store part of this operation Relaxed
if it happens,
and using Release
makes the load part Relaxed
.
Sourcepub fn compare_exchange(
&self,
current: ExecutorStatus,
new: ExecutorStatus,
success: Ordering,
failure: Ordering,
) -> Result<ExecutorStatus, ExecutorStatus>
pub fn compare_exchange( &self, current: ExecutorStatus, new: ExecutorStatus, success: Ordering, failure: Ordering, ) -> Result<ExecutorStatus, ExecutorStatus>
Stores a value into the atomic if the current value is the same as the current
value.
The return value is a result indicating whether the new value was written and containing the previous value.
On success this value is guaranteed to be equal to current
.
compare_exchange
takes two Ordering
arguments to describe the memory ordering of this operation. The first
describes the required ordering if the operation succeeds while the second describes the required ordering when
the operation fails. Using Acquire
as success ordering makes the store part of this operation Relaxed
, and
using Release
makes the successful load Relaxed
. The failure ordering can only be SeqCst
, Acquire
or
Relaxed
and must be equivalent to or weaker than the success ordering.
Sourcepub fn compare_exchange_weak(
&self,
current: ExecutorStatus,
new: ExecutorStatus,
success: Ordering,
failure: Ordering,
) -> Result<ExecutorStatus, ExecutorStatus>
pub fn compare_exchange_weak( &self, current: ExecutorStatus, new: ExecutorStatus, success: Ordering, failure: Ordering, ) -> Result<ExecutorStatus, ExecutorStatus>
Stores a value into the atomic if the current value is the same as the current
value.
Unlike compare_exchange
, this function is allowed to spuriously fail even when the comparison succeeds,
which can result in more efficient code on some platforms. The return value is a result indicating whether
the new value was written and containing the previous value.
compare_exchange_weak
takes two Ordering
arguments to describe the memory ordering of this operation.
The first describes the required ordering if the operation succeeds while the second describes the required
ordering when the operation fails. Using Acquire
as success ordering makes the store part of this operation
Relaxed
, and using Release
makes the successful load Relaxed
. The failure ordering can only be SeqCst
,
Acquire
or Relaxed
and must be equivalent to or weaker than the success ordering.