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>
impl<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>>> GenericSubscriber<T, D, R>
sourcepub fn new(atomic_ref: D) -> Self
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.
sourcepub fn wait<F: FnMut(T) -> bool>(&mut self, pred: F) -> Wait<'_, T, F> ⓘ
pub fn wait<F: FnMut(T) -> bool>(&mut self, pred: F) -> Wait<'_, T, F> ⓘ
Asynchronously wait for predicate to be true.
sourcepub fn wait_and_update<F: FnMut(T) -> Option<T>>(
&mut self,
map: F
) -> WaitAndUpdate<'_, T, F> ⓘ
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.