pub struct AtomicArcPtr<A: ArcPtr, D: Domain, W: WritePolicy> { /* private fields */ }Expand description
An atomic storage for generic Arc-like pointers.
All atomic operations are sequentially consistent and pseudo wait-free.
Implementations§
Source§impl<A: ArcPtr, D: Domain, W: WritePolicy> AtomicArcPtr<A, D, W>
impl<A: ArcPtr, D: Domain, W: WritePolicy> AtomicArcPtr<A, D, W>
Sourcepub fn load(&self) -> ArcPtrBorrow<A>
pub fn load(&self) -> ArcPtrBorrow<A>
Loads a borrowed Arc.
Sourcepub fn load_owned(&self) -> A
pub fn load_owned(&self) -> A
Loads an owned Arc.
Sourcepub fn load_if_outdated<'a>(&self, arc: &'a A) -> Result<&'a A, ArcPtrBorrow<A>>
pub fn load_if_outdated<'a>(&self, arc: &'a A) -> Result<&'a A, ArcPtrBorrow<A>>
Returns Arc reference passed if it is up-to-date, or load a borrowed Arc.
This method can be used in workflows where the atomic Arc is not expected to
be updated. Contrary to load_cached, it doesn’t require
a mutable reference.
Sourcepub fn load_cached<'a>(&self, cached: &'a mut A) -> &'a A
pub fn load_cached<'a>(&self, cached: &'a mut A) -> &'a A
Returns a reference to the cached Arc, updating it when it is outdated.
See Cache for a convenient wrapper around this method.
Sourcepub fn into_owned(self) -> A
pub fn into_owned(self) -> A
Consumes the atomic storage and returns the stored Arc.
Source§impl<A: ArcPtr, D: Domain> AtomicArcPtr<A, D, Concurrent>
impl<A: ArcPtr, D: Domain> AtomicArcPtr<A, D, Concurrent>
Sourcepub fn compare_exchange<C: ArcRef<A>>(
&self,
current: C,
new: A,
) -> Result<A, ArcPtrBorrow<A>>
pub fn compare_exchange<C: ArcRef<A>>( &self, current: C, new: A, ) -> Result<A, ArcPtrBorrow<A>>
Stores the new Arc if the current one matches the argument.
Returns the previous Arc if store succeeds, or loads the current Arc otherwise.
Sourcepub fn fetch_update<F: FnMut(&A) -> Option<R>, R: Into<A>>(
&self,
f: F,
) -> Result<A, ArcPtrBorrow<A>>
pub fn fetch_update<F: FnMut(&A) -> Option<R>, R: Into<A>>( &self, f: F, ) -> Result<A, ArcPtrBorrow<A>>
Fetches the current Arc, applies a function on it and tries to store the result if the current Arc has not changed.
Returns Err with the current Arc if the function returns None.
Source§impl<A: NonNullArcPtr, D: Domain, W: WritePolicy> AtomicArcPtr<Option<A>, D, W>
impl<A: NonNullArcPtr, D: Domain, W: WritePolicy> AtomicArcPtr<Option<A>, D, W>
Trait Implementations§
Source§impl<A: ArcPtr, D: Domain, W: WritePolicy> AtomicArcRef for AtomicArcPtr<A, D, W>
impl<A: ArcPtr, D: Domain, W: WritePolicy> AtomicArcRef for AtomicArcPtr<A, D, W>
Source§type LoadCached<'a> = &'a A
where
Self::Arc: 'a
type LoadCached<'a> = &'a A where Self::Arc: 'a
AtomicArc::load_cached.Source§fn load_owned(&self) -> Self::Owned
fn load_owned(&self) -> Self::Owned
Source§fn load_cached<'a>(&self, cached: &'a mut Self::Owned) -> Self::LoadCached<'a>
fn load_cached<'a>(&self, cached: &'a mut Self::Owned) -> Self::LoadCached<'a>
Source§impl<A: ArcPtr + Debug, D: Domain, W: WritePolicy> Debug for AtomicArcPtr<A, D, W>
impl<A: ArcPtr + Debug, D: Domain, W: WritePolicy> Debug for AtomicArcPtr<A, D, W>
Source§impl<A: ArcPtr + Default, D: Domain, W: WritePolicy> Default for AtomicArcPtr<A, D, W>
impl<A: ArcPtr + Default, D: Domain, W: WritePolicy> Default for AtomicArcPtr<A, D, W>
Source§impl<'de, A: ArcPtr + Deserialize<'de>, D: Domain, W: WritePolicy> Deserialize<'de> for AtomicArcPtr<A, D, W>
Available on crate feature serde only.
impl<'de, A: ArcPtr + Deserialize<'de>, D: Domain, W: WritePolicy> Deserialize<'de> for AtomicArcPtr<A, D, W>
serde only.