pub struct CrossProcessLock<L>{ /* private fields */ }
Expand description
A store-based lock for a Store
.
See the doc-comment of this module for more information.
Implementations§
Source§impl<L> CrossProcessLock<L>
impl<L> CrossProcessLock<L>
Sourcepub fn new(locker: L, lock_key: String, lock_holder: String) -> Self
pub fn new(locker: L, lock_key: String, lock_holder: String) -> Self
Create a new cross-process lock.
§Parameters
lock_key
: key in the key-value store to store the lock’s state.lock_holder
: identify the lock’s holder with this given value.
Sourcepub async fn try_lock_once(
&self,
) -> Result<Option<CrossProcessLockGuard>, CrossProcessLockError>
pub async fn try_lock_once( &self, ) -> Result<Option<CrossProcessLockGuard>, CrossProcessLockError>
Try to lock once, returns whether the lock was obtained or not.
Sourcepub async fn spin_lock(
&self,
max_backoff: Option<u32>,
) -> Result<CrossProcessLockGuard, CrossProcessLockError>
pub async fn spin_lock( &self, max_backoff: Option<u32>, ) -> Result<CrossProcessLockGuard, CrossProcessLockError>
Attempt to take the lock, with exponential backoff if the lock has already been taken before.
The max_backoff
parameter is the maximum time (in milliseconds) that
should be waited for, between two attempts. When that time is
reached a second time, the lock will stop attempting to get the lock
and will return a timeout error upon locking. If not provided,
will wait for MAX_BACKOFF_MS
.
Sourcepub fn lock_holder(&self) -> &str
pub fn lock_holder(&self) -> &str
Returns the value in the database that represents the holder’s identifier.
Trait Implementations§
Source§impl<L> Clone for CrossProcessLock<L>
impl<L> Clone for CrossProcessLock<L>
Source§fn clone(&self) -> CrossProcessLock<L>
fn clone(&self) -> CrossProcessLock<L>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<L> Freeze for CrossProcessLock<L>where
L: Freeze,
impl<L> !RefUnwindSafe for CrossProcessLock<L>
impl<L> Send for CrossProcessLock<L>
impl<L> Sync for CrossProcessLock<L>where
L: Sync,
impl<L> Unpin for CrossProcessLock<L>where
L: Unpin,
impl<L> !UnwindSafe for CrossProcessLock<L>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>