Skip to main content

FutexMutex

Struct FutexMutex 

Source
pub struct FutexMutex<T: ?Sized> { /* private fields */ }
Expand description

Move-safe, zero-allocation 3-state futex mutex (0 = unlocked, 1 = locked, 2 = contended).

Implementations§

Source§

impl<T> FutexMutex<T>

Source

pub const fn new(value: T) -> Self

Creates a new unlocked FutexMutex wrapping value.

Source

pub fn into_inner(self) -> T

Consumes the mutex and returns its inner value.

Source§

impl<T: ?Sized> FutexMutex<T>

Source

pub fn try_lock(&self) -> Option<FutexMutexGuard<'_, T>>

Attempts to acquire the mutex without blocking.

Source

pub fn lock(&self) -> FutexMutexGuard<'_, T>

Acquires the mutex, spinning briefly before blocking via futex wait under contention.

Source

pub unsafe fn raw_unlock(&self)

Releases the mutex without a guard (used by FutexMutexGuard drop).

§Safety

The caller must currently hold the lock on self and must not access the protected value after calling raw_unlock without re-acquiring the lock.

Source

pub fn get_mut(&mut self) -> &mut T

Returns a mutable reference to the underlying data when holding exclusive &mut self.

Trait Implementations§

Source§

impl<T: ?Sized + Send> Send for FutexMutex<T>

Source§

impl<T: ?Sized + Send> Sync for FutexMutex<T>

Auto Trait Implementations§

§

impl<T> !Freeze for FutexMutex<T>

§

impl<T> !RefUnwindSafe for FutexMutex<T>

§

impl<T> Forget for FutexMutex<T>
where T: ?Sized,

§

impl<T> Move for FutexMutex<T>
where T: ?Sized,

§

impl<T> Unpin for FutexMutex<T>
where UnsafeCell<T>: Unpin, T: ?Sized,

§

impl<T> UnsafeUnpin for FutexMutex<T>
where UnsafeCell<T>: UnsafeUnpin, T: ?Sized,

§

impl<T> UnwindSafe for FutexMutex<T>
where UnsafeCell<T>: UnwindSafe, T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.