pub struct InMemoryBackend { /* private fields */ }Expand description
A single-process, in-memory LockBackend.
Fully functional: fencing tokens are strictly monotonic per key, and an expired lease is reclaimable by the next acquirer. This is the backend the deterministic simulation test exercises.
Implementations§
Source§impl InMemoryBackend
impl InMemoryBackend
Sourcepub fn tracked_keys(&self) -> usize
pub fn tracked_keys(&self) -> usize
Number of tracked keys (held or historically seen). Test helper.
Trait Implementations§
Source§impl Default for InMemoryBackend
impl Default for InMemoryBackend
Source§impl LockBackend for InMemoryBackend
impl LockBackend for InMemoryBackend
Source§fn try_acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(u64, Instant)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_acquire<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(u64, Instant)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Attempt to acquire
key for ttl. On success returns the fencing token
(strictly monotonic per key) and the local lease deadline.Source§fn try_renew<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Instant>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn try_renew<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Instant>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Renew a lease previously acquired with
token, extending it by ttl.
Returns the new local lease deadline.Source§fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn release<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Release a lease. A no-op if
token is already stale (someone else owns
the key), so releasing an expired guard is harmless.Auto Trait Implementations§
impl !RefUnwindSafe for InMemoryBackend
impl Freeze for InMemoryBackend
impl Send for InMemoryBackend
impl Sync for InMemoryBackend
impl Unpin for InMemoryBackend
impl UnsafeUnpin for InMemoryBackend
impl UnwindSafe for InMemoryBackend
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