pub struct CowTransactionGuard<'tra, ITEM: Send + Debug> { /* private fields */ }Expand description
A guard which guards the CoW read/write operation. During this operation, the instance is borrowed and copied or clonned or default or new instance created.
This method of modifying does not require to release all borrows i.e CowReadGuard.
Instead the value in the base will be replaced and anyone who will request the
borrow after the update will see the new value. The rest who keeps borrow would
still use old value.
Implementations§
Source§impl<'tra, ITEM: Send + Debug> CowTransactionGuard<'tra, ITEM>
impl<'tra, ITEM: Send + Debug> CowTransactionGuard<'tra, ITEM>
Sourcepub fn get_previous(&self) -> &ITEM
pub fn get_previous(&self) -> &ITEM
Returns the previous reference to the item (old value) which will be replaced.
Sourcepub fn completed(self, try_update: bool) -> Result<(), (Self, CowGuardError)>
pub fn completed(self, try_update: bool) -> Result<(), (Self, CowGuardError)>
Completes the transaction by attempting to replace the old item with new item
in the base. If argument try_update is set to true, the completed will not block,
but return an error to repeat the attempt later.
§Arguments
The instance is consumed.
try_update - if set to true does not block if exclusive lock is pending.
§Returns
A Result is returned with:
-
Result::Ok with the guard is returned.
-
Result::Err with the error is returned:
-
CowGuardError::Poisoned - if the exclusive was poisoned i.e thread panicked.
-
CowGuardError::ExclusiveLockPending - if the argument
try_borrowis set totrue.