StripedLock

Struct StripedLock 

Source
pub struct StripedLock<K, H = BuildHasherDefault<DefaultHasher>>
where K: Hash, H: BuildHasher,
{ /* private fields */ }

Implementations§

Source§

impl<K> StripedLock<K, BuildHasherDefault<DefaultHasher>>
where K: Hash,

Source

pub fn new(locks: NonZeroUsize) -> Self

Create a new StripedLock instance with rust’s default hasher.

§Arguments
  • locks - The number of inner locks. Increase to reduce collisions.
Source§

impl<K, H> StripedLock<K, H>
where K: Hash, H: BuildHasher,

Source

pub fn with_hasher(hasher_builder: H, locks: NonZeroUsize) -> Self

Create a new StripedLock instance.

§Arguments
  • locks - The number of inner locks. Increase to reduce collisions.
  • hasher_builder - The factory of hashers.
Source

pub fn lock(&self, key: K) -> Result<StripedLockGuard<'_>, StripedPoisonError>

Lock on the key. Use lock_batch if you want to lock on multiple keys.

§Arguments
  • key - The key to lock on.
Source

pub fn lock_batch<B>( &self, batch: B, ) -> Result<StripedBatchLockGuard<'_>, StripedPoisonError>
where B: KeyBatch<K, H>,

Lock on the key. Use lock_batch if you want to lock on multiple keys.

§Arguments
  • batch - The batch of keys to lock on. May be up to 4.
§Example
let sl: StripedLock<char> = StripedLock::new(NonZeroUsize::new(4).unwrap());
sl.lock_batch(('a', 'b', 'c', 'd'));
Source

pub fn is_poisoned(&self, key: K) -> bool

Check if the mutex at the given key is poisoned.

Source

pub fn clear_poison(&self, key: K)

Auto Trait Implementations§

§

impl<K, H> Freeze for StripedLock<K, H>
where H: Freeze,

§

impl<K, H> RefUnwindSafe for StripedLock<K, H>

§

impl<K, H> Send for StripedLock<K, H>
where H: Send, K: Send,

§

impl<K, H> Sync for StripedLock<K, H>
where H: Sync, K: Sync,

§

impl<K, H> Unpin for StripedLock<K, H>
where H: Unpin, K: Unpin,

§

impl<K, H> UnwindSafe for StripedLock<K, H>
where H: UnwindSafe, K: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.