pub struct GenericMutex<MutexType: RawMutex, T> { /* private fields */ }
Expand description
A futures-aware mutex.
Implementations§
Source§impl<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> ⓘ
pub fn lock(&self) -> GenericMutexLockFuture<'_, 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§
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> !Freeze for GenericMutex<MutexType, T>
impl<MutexType, T> !RefUnwindSafe for GenericMutex<MutexType, T>
impl<MutexType, T> Unpin for GenericMutex<MutexType, T>
impl<MutexType, T> UnwindSafe for GenericMutex<MutexType, T>where
T: UnwindSafe,
MutexType: 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