pub struct AtomicWifiState(/* private fields */);
Expand description
A wrapper around WifiState
which can be safely shared between threads.
This type uses an AtomicUsize
to store the enum value.
Implementations§
Source§impl AtomicWifiState
impl AtomicWifiState
Sourcepub const fn new(v: WifiState) -> AtomicWifiState
pub const fn new(v: WifiState) -> AtomicWifiState
Creates a new atomic WifiState
.
Sourcepub fn into_inner(self) -> WifiState
pub fn into_inner(self) -> WifiState
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: WifiState)
pub fn set(&mut self, v: WifiState)
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) -> WifiState
pub fn get(&mut self) -> WifiState
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: WifiState) -> WifiState
pub fn swap_mut(&mut self, v: WifiState) -> WifiState
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) -> WifiState
pub fn load(&self, order: Ordering) -> WifiState
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: WifiState, order: Ordering)
pub fn store(&self, val: WifiState, 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
.
Sourcepub fn swap(&self, val: WifiState, order: Ordering) -> WifiState
pub fn swap(&self, val: WifiState, order: Ordering) -> WifiState
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_exchange(
&self,
current: WifiState,
new: WifiState,
success: Ordering,
failure: Ordering,
) -> Result<WifiState, WifiState>
pub fn compare_exchange( &self, current: WifiState, new: WifiState, success: Ordering, failure: Ordering, ) -> Result<WifiState, WifiState>
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: WifiState,
new: WifiState,
success: Ordering,
failure: Ordering,
) -> Result<WifiState, WifiState>
pub fn compare_exchange_weak( &self, current: WifiState, new: WifiState, success: Ordering, failure: Ordering, ) -> Result<WifiState, WifiState>
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.