pub struct ICoWCopy<'copy, 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 not exclusive, so it does not prevent
multiple CoW operations. Normally, if some object which may be written
simultaniously i.e lost connection to remote server and reconnect is required,
the exclusive lock would be more desirable.
Implementations§
Source§impl<'copy, ITEM: Debug + Send> ICoWCopy<'copy, ITEM>
impl<'copy, ITEM: Debug + Send> 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.
§Returns
The Result::Err is returned with:
Error types ICoWError:
-
ICoWError::ExclusiveLockPending - if exclusivly locked from another thread.
-
ICoWError::WouldBlock - is returned if
try_writereturns TryLockError::WouldBlock and the lock is not exclusive.
Sourcepub fn commit_blocking(self) -> Result<(), Self>
pub fn commit_blocking(self) -> 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 Result::Err is returned, the instance is locked exclusivly.
§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.