Type Alias async_atomic::Subscriber

source ·
pub type Subscriber<T> = GenericSubscriber<T, Arc<Atomic<T>>>;
Expand description

Subscriber of the atomic variable.

References to an underlying atomic could be obtained using Deref.

Aliased Type§

struct Subscriber<T> { /* private fields */ }

Implementations§

source§

impl<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>>> GenericSubscriber<T, D, R>

source

pub fn new(atomic_ref: D) -> Self

Create subscriber for atomic.

If there are multiple subscribers for single atomic then only one of them is notified.

source

pub fn wait<F: FnMut(T) -> bool>(&mut self, pred: F) -> Wait<'_, T, F>

Asynchronously wait for predicate to be true.

source

pub fn wait_and_update<F: FnMut(T) -> Option<T>>( &mut self, map: F ) -> WaitAndUpdate<'_, T, F>

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

This is an asynchronous version of Atomic::fetch_update.

source§

impl<T: Copy + PartialEq, D: AsRef<R>, R: AsRef<Atomic<T>>> GenericSubscriber<T, D, R>

source

pub fn into_stream(self) -> Changed<T, D, R>

Convert subscriber into stream that yields when value is changed.

Trait Implementations§

source§

impl<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>>> AsRef<D> for GenericSubscriber<T, D, R>

source§

fn as_ref(&self) -> &D

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>>> Deref for GenericSubscriber<T, D, R>

§

type Target = D

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.