pub struct ICoWLock<'lock, ITEM: Debug + Send> { /* private fields */ }Expand description
A write-guard which holds new value to which the new values are written. And previous value too. This type of guard is exclusive, so multiple CoW operations CANNOT be performed in parallel which is good for instance update without racing. The readers are also waiting until the changes are commited.
Implementations§
Source§impl<'lock, ITEM: Debug + Send> ICoWLock<'lock, ITEM>
impl<'lock, ITEM: Debug + Send> ICoWLock<'lock, ITEM>
Sourcepub fn commit(self)
pub fn commit(self)
Commits the changes made in the guarded variable.
§Returns
Always returns Result::Ok, but the atomic realization
would return Result::Err if:
The Result::Err is retruned if race condition happens i.e when updating the inner atomic ptr fails because someone have already changed the value.
Sourcepub fn commit_wiht_into_inner(self) -> Arc<ITEM>
pub fn commit_wiht_into_inner(self) -> Arc<ITEM>
Commits the changes made in the guarded variable and returning the atomic reference Arc to previous.
Trait Implementations§
Auto Trait Implementations§
impl<'lock, ITEM> Freeze for ICoWLock<'lock, ITEM>where
ITEM: Freeze,
impl<'lock, ITEM> RefUnwindSafe for ICoWLock<'lock, ITEM>where
ITEM: RefUnwindSafe,
impl<'lock, ITEM> !Send for ICoWLock<'lock, ITEM>
impl<'lock, ITEM> Sync for ICoWLock<'lock, ITEM>where
ITEM: Sync,
impl<'lock, ITEM> Unpin for ICoWLock<'lock, ITEM>where
ITEM: Unpin,
impl<'lock, ITEM> UnwindSafe for ICoWLock<'lock, ITEM>where
ITEM: UnwindSafe,
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