futures_intrusive::sync

Struct GenericMutex

Source
pub struct GenericMutex<MutexType: RawMutex, T> { /* private fields */ }
Expand description

A futures-aware mutex.

Implementations§

Source§

impl<MutexType: RawMutex, T> GenericMutex<MutexType, T>

Source

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.

Source

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.

Source

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.

Source

pub fn is_locked(&self) -> bool

Returns whether the mutex is locked.

Trait Implementations§

Source§

impl<MutexType: RawMutex, T: Debug> Debug for GenericMutex<MutexType, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Send, MutexType: RawMutex + Send> Send for GenericMutex<MutexType, T>

Source§

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>
where T: Unpin, MutexType: Unpin,

§

impl<MutexType, T> UnwindSafe for GenericMutex<MutexType, T>
where T: UnwindSafe, MutexType: 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.