AvrAtomic

Struct AvrAtomic 

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

A fast atomic type for 8-bit values on AVR microcontrollers.

This type has no IRQ-disable/restore or other locking overhead on AVR.

This type provides atomic load and store operations for u8, i8, and bool by default. But you can extend the supported types with your own types by implementing AvrAtomicConvert.

§Internal implementation

Note that the internal representation of the data storage always is a u8, no matter that type T actually is.

Implementations§

Source§

impl<T> AvrAtomic<T>

Source

pub const fn new() -> AvrAtomic<T>

Create a new AvrAtomic with the initial interior raw data being 0_u8.

Source

pub fn load_raw(&self) -> u8

Atomically read as raw u8 byte.

This atomic read is also a full SeqCst memory barrier.

Source

pub unsafe fn store_raw(&self, value: u8)

Atomically write as raw u8 byte.

This atomic write is also a full SeqCst memory barrier.

§Safety

The caller must ensure that value is properly encoded to represent a valid T.

Source§

impl<T: AvrAtomicConvert> AvrAtomic<T>

Source

pub fn new_value(value: T) -> Self

Create a new AvrAtomic initialized to value.

Source

pub fn load(&self) -> T

Atomically read the current value.

This atomic read is also a full SeqCst memory barrier.

Source

pub fn store(&self, value: T)

Atomically write a new value.

This atomic write is also a full SeqCst memory barrier.

Trait Implementations§

Source§

impl<T> Default for AvrAtomic<T>

Source§

fn default() -> Self

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

impl<T: Send> Sync for AvrAtomic<T>

Auto Trait Implementations§

§

impl<T> !Freeze for AvrAtomic<T>

§

impl<T> !RefUnwindSafe for AvrAtomic<T>

§

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

§

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

§

impl<T> UnwindSafe for AvrAtomic<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, 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.