pub struct ICoWCopy<'copy, ITEM: Sized> { /* private fields */ }Expand description
A write-guard which holds new value to which the new data is written. And previous value too. This type of guard is not exclusive, so multiple CoW operations may be performed in parallel which is not normally needed.
The changes made in the current instance becomes visible for the rest of the threads only after commit.
Implementations§
Source§impl<'copy, ITEM: Sized> ICoWCopy<'copy, ITEM>
impl<'copy, ITEM: Sized> ICoWCopy<'copy, ITEM>
Sourcepub fn commit(self) -> Result<(), (ICoWError, Self)>
pub fn commit(self) -> Result<(), (ICoWError, Self)>
Commits the changes made in the guarded variable. A non-blocking
function. It will not block the thread completly and returns the
ICoWError::WouldBlock if attempt to grab the pointer atomically
fails in reasonable time. for blocking commit use
Self::commit_blocking.
§Returns
If operation was successfull, a Result::Ok is returned.
The Result::Err is retruned as tuple
Error types:
-
ICoWError::ExclusiveLockPending - if exclusivly locked from another thread.
-
ICoWError::WouldBlock - if “exponential backoff has completed and blocking the thread is advised”
Sourcepub fn commit_blocking(self, ignore_excl: bool) -> Result<(), Self>
pub fn commit_blocking(self, ignore_excl: bool) -> Result<(), Self>
Commits the changes to the mainstream instance of ICoW. A partially non-blocking function. It would wait for an exclusive access ignoring the ICoWError::WouldBlock only if the instance is not locked exclusivly.
If argument ignore_excl is set to true, the instance will not return
ICoWError::ExclusiveLockPending error and wait until the lock release.
If Result::Err is returned, the instance is locked exclusivly.
(only if ignore_excl argument is set to true)
§Returns
The Result::Err is returned with:
ICoWCopy commited instance itself.
Sourcepub fn into_inner(self) -> ITEM
pub fn into_inner(self) -> ITEM
Drops the instance without commiting changes returning
a copy, clone, default, or new i.e what was in the new field
of the instance.