Struct async_atomic::GenericSubscriber
source · pub struct GenericSubscriber<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>> = Atomic<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
.
Trait Implementations§
Auto Trait Implementations§
impl<T, D, R> Freeze for GenericSubscriber<T, D, R>where
D: Freeze,
impl<T, D, R> RefUnwindSafe for GenericSubscriber<T, D, R>
impl<T, D, R> Send for GenericSubscriber<T, D, R>
impl<T, D, R> Sync for GenericSubscriber<T, D, R>
impl<T, D, R> Unpin for GenericSubscriber<T, D, R>
impl<T, D, R> UnwindSafe for GenericSubscriber<T, D, R>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more