Struct esp_wifi::wifi::AtomicWifiState

source ·
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

source

pub const fn new(v: WifiState) -> AtomicWifiState

Creates a new atomic WifiState.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

Trait Implementations§

source§

impl Debug for AtomicWifiState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<WifiState> for AtomicWifiState

source§

fn from(val: WifiState) -> AtomicWifiState

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !Freeze for AtomicWifiState

§

impl RefUnwindSafe for AtomicWifiState

§

impl Send for AtomicWifiState

§

impl Sync for AtomicWifiState

§

impl Unpin for AtomicWifiState

§

impl UnwindSafe for AtomicWifiState

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.