pub enum SmartMutex<T> {
Standard(Mutex<T>),
ParkingLot(Mutex<T>),
}
Expand description
Smart mutex that chooses the best implementation based on usage patterns
Variants§
Standard(Mutex<T>)
Use standard mutex for low-contention scenarios
ParkingLot(Mutex<T>)
Use parking_lot for high-contention scenarios
Implementations§
Source§impl<T> SmartMutex<T>
impl<T> SmartMutex<T>
Sourcepub fn lock(&self) -> SmartMutexGuard<'_, T>
pub fn lock(&self) -> SmartMutexGuard<'_, T>
Lock with automatic contention detection
Sourcepub fn try_lock(&self) -> Option<SmartMutexGuard<'_, T>>
pub fn try_lock(&self) -> Option<SmartMutexGuard<'_, T>>
Try to lock without blocking
Auto Trait Implementations§
impl<T> !Freeze for SmartMutex<T>
impl<T> !RefUnwindSafe for SmartMutex<T>
impl<T> Send for SmartMutex<T>where
T: Send,
impl<T> Sync for SmartMutex<T>where
T: Send,
impl<T> Unpin for SmartMutex<T>where
T: Unpin,
impl<T> UnwindSafe for SmartMutex<T>where
T: 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more