Trait AsyncAtomicRef

Source
pub trait AsyncAtomicRef {
    type Item: Atom;

    // Required method
    fn as_atomic(&self) -> &AsyncAtomic<Self::Item>;

    // Provided methods
    fn wait<F: FnMut(Self::Item) -> bool>(&self, pred: F) -> Wait<&Self, F>  { ... }
    fn wait_and_update<F: FnMut(Self::Item) -> Option<Self::Item>>(
        &self,
        map: F,
    ) -> WaitAndUpdate<&Self, F>  { ... }
    fn changed(self) -> Changed<Self> 
       where Self: Sized,
             Self::Item: PartialEq + Clone { ... }
}
Expand description

Generic reference to async atomic.

Contains async methods which returns futures that wait for atomic value change.

After one of the futures polled, all previously polled futures will not wake. This may cause a deadlock, however it is not an UB, so these methods are safe.

Required Associated Types§

Source

type Item: Atom

Type stored in atomic.

Required Methods§

Source

fn as_atomic(&self) -> &AsyncAtomic<Self::Item>

Get reference to original atomic structure.

Provided Methods§

Source

fn wait<F: FnMut(Self::Item) -> bool>(&self, pred: F) -> Wait<&Self, F>

Asynchronously wait for predicate to be true.

Source

fn wait_and_update<F: FnMut(Self::Item) -> Option<Self::Item>>( &self, map: F, ) -> WaitAndUpdate<&Self, F>

Asynchronously wait until map returned Some(x) and then store x in atomic.

This is an asynchronous version of fetch_update.

Source

fn changed(self) -> Changed<Self>
where Self: Sized, Self::Item: PartialEq + Clone,

Convert subscriber into stream that yields when value is changed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§