pub struct LockManager<K: Eq + Hash + Clone> { /* private fields */ }
Expand description
A thread-safe lock manager that provides key-based locking capabilities.
The LockManager
allows concurrent access control based on keys of type K
.
It supports both single-key and batch locking operations.
Type parameter:
K
: The key type that must implementEq + Hash + Clone
traits
Implementations§
Source§impl<K: Eq + Hash + Clone> LockManager<K>
impl<K: Eq + Hash + Clone> LockManager<K>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new LockManager
with the specified capacity.
§Arguments
capacity
- The initial capacity for the internal map
Sourcepub fn with_capacity_and_shard_amount(
capacity: usize,
shard_amount: usize,
) -> Self
pub fn with_capacity_and_shard_amount( capacity: usize, shard_amount: usize, ) -> Self
Creates a new LockManager
with specified capacity and shard amount.
§Arguments
capacity
- The initial capacity for the internal mapshard_amount
- The number of shards to use for internal concurrency
Sourcepub fn batch_lock<'a, 'b>(
&'a self,
keys: &'b BTreeSet<K>,
) -> BatchLockGuard<'a, 'b, K>
pub fn batch_lock<'a, 'b>( &'a self, keys: &'b BTreeSet<K>, ) -> BatchLockGuard<'a, 'b, K>
Acquires locks for multiple keys atomically.
This method will block until all locks can be acquired. The locks are acquired in a consistent order to prevent deadlocks.
§Arguments
keys
- ABTreeSet
containing the keys to lock
§Returns
Returns a BatchLockGuard
that will automatically release all locks when dropped
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for LockManager<K>
impl<K> !RefUnwindSafe for LockManager<K>
impl<K> Send for LockManager<K>where
K: Send,
impl<K> Sync for LockManager<K>
impl<K> Unpin for LockManager<K>
impl<K> UnwindSafe for LockManager<K>where
K: UnwindSafe,
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