Skip to main content

RecursiveMutex

Struct RecursiveMutex 

Source
pub struct RecursiveMutex { /* private fields */ }
Expand description

RAII wrapper around a recursive mutex.

Implementations§

Source§

impl RecursiveMutex

Source

pub fn new() -> Result<Self>

Create a new recursive mutex via heap allocation (only in heap mode).

Source

pub fn create(storage: &'static RecursiveMutexStorage) -> Result<Self>

Mode-agnostic constructor (see Mutex::create).

Source

pub fn lock(&self) -> Result<RecursiveMutexGuard<'_>>

Acquire the recursive mutex, blocking indefinitely. Returns an RAII guard that releases one level of the lock on drop. Same thread may call this multiple times — each guard releases one level when dropped.

Source

pub fn try_lock(&self) -> Result<RecursiveMutexGuard<'_>>

Attempt to acquire the recursive mutex without blocking.

§Errors

Returns Error::WouldBlock if held by a different thread.

Source

pub fn try_lock_for(&self, d: Duration) -> Result<RecursiveMutexGuard<'_>>

Attempt to acquire the recursive mutex, waiting up to d.

Source

pub fn try_lock_until( &self, deadline: Instant, ) -> Result<RecursiveMutexGuard<'_>>

Attempt to acquire the recursive mutex by the given deadline. Use Instant::FOREVER for an indefinite wait.

Source

pub fn unlock(&self)

Release one level of the recursive lock.

Prefer letting the RAII guard (RecursiveMutexGuard) drop release the lock; this is kept pub for parity with the C API.

Trait Implementations§

Source§

impl Debug for RecursiveMutex

Source§

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

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

impl Drop for RecursiveMutex

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for RecursiveMutex

Source§

impl Sync for RecursiveMutex

Auto Trait Implementations§

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.