Struct futures_intrusive::sync::GenericMutex
source · pub struct GenericMutex<MutexType: RawMutex, T> { /* private fields */ }
Expand description
A futures-aware mutex.
Implementations
sourceimpl<MutexType: RawMutex, T> GenericMutex<MutexType, T>
impl<MutexType: RawMutex, T> GenericMutex<MutexType, T>
sourcepub fn new(value: T, is_fair: bool) -> GenericMutex<MutexType, T>
pub fn new(value: T, is_fair: bool) -> GenericMutex<MutexType, T>
Creates a new futures-aware mutex.
is_fair
defines whether the Mutex
should behave be fair regarding the
order of waiters. A fair Mutex
will only allow the first waiter which
tried to lock but failed to lock the Mutex
once it’s available again.
Other waiters must wait until either this locking attempt completes, and
the Mutex
gets unlocked again, or until the MutexLockFuture
which
tried to gain the lock is dropped.
sourcepub fn lock(&self) -> GenericMutexLockFuture<'_, MutexType, T>ⓘNotable traits for GenericMutexLockFuture<'a, MutexType, T>impl<'a, MutexType: RawMutex, T> Future for GenericMutexLockFuture<'a, MutexType, T> type Output = GenericMutexGuard<'a, MutexType, T>;
pub fn lock(&self) -> GenericMutexLockFuture<'_, MutexType, T>ⓘNotable traits for GenericMutexLockFuture<'a, MutexType, T>impl<'a, MutexType: RawMutex, T> Future for GenericMutexLockFuture<'a, MutexType, T> type Output = GenericMutexGuard<'a, MutexType, T>;
Acquire the mutex asynchronously.
This method returns a future that will resolve once the mutex has been successfully acquired.
sourcepub fn try_lock(&self) -> Option<GenericMutexGuard<'_, MutexType, T>>
pub fn try_lock(&self) -> Option<GenericMutexGuard<'_, MutexType, T>>
Tries to acquire the mutex
If acquiring the mutex is successful, a GenericMutexGuard
will be returned, which allows to access the contained data.
Otherwise None
will be returned.
Trait Implementations
sourceimpl<MutexType: RawMutex, T: Debug> Debug for GenericMutex<MutexType, T>
impl<MutexType: RawMutex, T: Debug> Debug for GenericMutex<MutexType, T>
impl<T: Send, MutexType: RawMutex + Send> Send for GenericMutex<MutexType, T>
impl<T: Send, MutexType: RawMutex + Sync> Sync for GenericMutex<MutexType, T>
Auto Trait Implementations
impl<MutexType, T> !RefUnwindSafe for GenericMutex<MutexType, T>
impl<MutexType, T> Unpin for GenericMutex<MutexType, T>where
MutexType: Unpin,
T: Unpin,
impl<MutexType, T> UnwindSafe for GenericMutex<MutexType, T>where
MutexType: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more