AtomicCell

Struct AtomicCell 

Source
pub struct AtomicCell<T> { /* private fields */ }
Expand description

A container to allow atomic access to the contained object

Implementations§

Source§

impl<T: Send + Copy> AtomicCell<T>

Source

pub fn load(&self) -> T

Read the value of the AtomicCell

Source

pub fn borrow<'a>(&'a self, cs: CriticalSection<'a>) -> &'a Cell<T>

Borrow a reference to the contained value

A critical section must be obtained by the called and provided

Source

pub fn fetch_update(&self, f: impl FnMut(T) -> Option<T>) -> Result<T, T>

Perform atomic modification of the contained value

This operation will be performed in a critical section, so it will block all IRQs until the function returns.

Source§

impl<T: Send> AtomicCell<T>

Source

pub const fn new(value: T) -> Self

Create a new AtomicCell with the provided value

Source

pub fn store(&self, value: T)

Replace the value of the AtomicCell

Source§

impl<T: Send + Default> AtomicCell<T>

Source

pub fn take(&self) -> T

Return the contained value, and replace it with a default value

Source§

impl<T: Copy + Add<Output = T>> AtomicCell<T>

Source

pub fn fetch_add(&self, value: T) -> T

Atomically add value to the contained value

Trait Implementations§

Source§

impl<T: Default> Default for AtomicCell<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Default + Copy + Send> LoadStore<T> for AtomicCell<T>

Source§

fn load(&self) -> T

Read the value
Source§

fn store(&self, value: T)

Store a new value to the

Auto Trait Implementations§

§

impl<T> !Freeze for AtomicCell<T>

§

impl<T> !RefUnwindSafe for AtomicCell<T>

§

impl<T> Send for AtomicCell<T>
where T: Send,

§

impl<T> Sync for AtomicCell<T>
where T: Send,

§

impl<T> Unpin for AtomicCell<T>
where T: Unpin,

§

impl<T> UnwindSafe for AtomicCell<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.