pub struct AsyncAtomic<T: Atom> { /* private fields */ }
Expand description
Atomic value that also contains Waker
to notify subscriber asynchronously.
There is only a single waker, so there should be only single subscription at a time. Otherwise older subscriptions will not receive updates anymore.
Implementations§
Source§impl<T: Atom> AsyncAtomic<T>
impl<T: Atom> AsyncAtomic<T>
pub fn new(value: T) -> Self
pub const fn from_impl(repr: <T::Repr as PrimitiveAtom>::Impl) -> Self
pub fn load(&self) -> T
pub fn store(&self, val: T)
pub fn swap(&self, val: T) -> T
pub fn compare_exchange(&self, current: T, new: T) -> Result<T, T>
pub fn fetch_update<F: FnMut(T) -> Option<T>>(&self, f: F) -> Result<T, T>
Source§impl<T: AtomLogic> AsyncAtomic<T>where
T::Repr: PrimitiveAtomLogic,
impl<T: AtomLogic> AsyncAtomic<T>where
T::Repr: PrimitiveAtomLogic,
Source§impl<T: AtomInteger> AsyncAtomic<T>where
T::Repr: PrimitiveAtomInteger,
impl<T: AtomInteger> AsyncAtomic<T>where
T::Repr: PrimitiveAtomInteger,
Trait Implementations§
Source§impl<T: Atom> AsRef<AsyncAtomic<T>> for AsyncAtomic<T>
impl<T: Atom> AsRef<AsyncAtomic<T>> for AsyncAtomic<T>
Source§fn as_ref(&self) -> &AsyncAtomic<T>
fn as_ref(&self) -> &AsyncAtomic<T>
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<T: Atom> AsyncAtomicRef for AsyncAtomic<T>
impl<T: Atom> AsyncAtomicRef for AsyncAtomic<T>
Source§fn as_atomic(&self) -> &AsyncAtomic<Self::Item>
fn as_atomic(&self) -> &AsyncAtomic<Self::Item>
Get reference to original atomic structure.
Source§fn wait<F: FnMut(Self::Item) -> bool>(&self, pred: F) -> Wait<&Self, F> ⓘ
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> ⓘ
fn wait_and_update<F: FnMut(Self::Item) -> Option<Self::Item>>( &self, map: F, ) -> WaitAndUpdate<&Self, F> ⓘ
Auto Trait Implementations§
impl<T> !Freeze for AsyncAtomic<T>
impl<T> !RefUnwindSafe for AsyncAtomic<T>
impl<T> Send for AsyncAtomic<T>
impl<T> Sync for AsyncAtomic<T>
impl<T> Unpin for AsyncAtomic<T>
impl<T> UnwindSafe for AsyncAtomic<T>
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