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 poll
ed, all previously poll
ed futures will not wake.
This may cause a deadlock, however it is not an UB, so these methods are safe.
Required Associated Types§
Required Methods§
Sourcefn as_atomic(&self) -> &AsyncAtomic<Self::Item>
fn as_atomic(&self) -> &AsyncAtomic<Self::Item>
Get reference to original atomic structure.
Provided Methods§
Sourcefn 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
.
Sourcefn 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> ⓘ
Asynchronously wait until map
returned Some(x)
and then store x
in atomic.
This is an asynchronous version of fetch_update
.
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.