pub struct LockBuilder { /* private fields */ }
Expand description
Builds a lock from a ConcreteLock implementation using the configurations enabled. See below for all possible configurations. Note, by implementing the ConcreteLock implementation you can wrap it with a LockBuilder to create the Lock interface used in all utility functions.
Implementations§
Source§impl LockBuilder
impl LockBuilder
Sourcepub fn enable_silent_unlock(self)
pub fn enable_silent_unlock(self)
If the unlock fails, intermediate computation may be lost. This may not be the behaviour you wished for, so enable silent_unlock. You can then check the lock status afterwards by performing Lock::status.
Sourcepub fn enable_try_lock(self)
pub fn enable_try_lock(self)
If the lock is already taken, by default we would hang until it was our turn. By enabling ‘try_lock’ we instead try to lock but fail immediately with SimpleLockError::AlreadyLocked if we could not acquire it.
Sourcepub fn with_silent_unlock(self) -> Self
pub fn with_silent_unlock(self) -> Self
Performs enable_status_unlock
and then returns self so that we can chain
additional configurations or a call to build
.
Sourcepub fn with_try_lock(self) -> Self
pub fn with_try_lock(self) -> Self
Performs enable_try_lock
and then returns self so that we can chain
additional configurations or a call to build
.
Sourcepub fn wrap(
&self,
concrete: Box<dyn ConcreteLock>,
) -> SimpleLockResult<Box<dyn Lock>>
pub fn wrap( &self, concrete: Box<dyn ConcreteLock>, ) -> SimpleLockResult<Box<dyn Lock>>
Wraps a ConcreteLock with the configurations enabled with this LockBuilder and returns the simplified Lock interface.
Trait Implementations§
Source§impl Clone for LockBuilder
impl Clone for LockBuilder
Source§fn clone(&self) -> LockBuilder
fn clone(&self) -> LockBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more