Struct TryMutex

Source
pub struct TryMutex<T> { /* private fields */ }
Expand description

A mutual exclusion primitive that does not support blocking or poisoning. This results in a simpler and faster implementation.

Implementations§

Source§

impl<T> TryMutex<T>

Source

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

Create a new mutex in unlocked state.

Source

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

Attemps to acquire a lock on this mutex. If this mutex is currently locked, None is returned. Otherwise a RAII guard is returned. The lock will be unlocked when the guard is dropped.

Source

pub fn into_inner(self) -> T

Consumes this mutex, returning the underlying data.

Source

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

Retrieve a mutable reference to the underlying data. Since this mutably borrows the mutex, no actual locking needs to take place.

Trait Implementations§

Source§

impl<T: Debug> Debug for TryMutex<T>

Source§

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

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

impl<T: Default> Default for TryMutex<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> From<T> for TryMutex<T>

Source§

fn from(t: T) -> Self

Converts to this type from the input type.
Source§

impl<T> RefUnwindSafe for TryMutex<T>

Source§

impl<T: Send> Send for TryMutex<T>

Source§

impl<T: Send> Sync for TryMutex<T>

Source§

impl<T> UnwindSafe for TryMutex<T>

Auto Trait Implementations§

§

impl<T> !Freeze for TryMutex<T>

§

impl<T> Unpin for TryMutex<T>
where T: Unpin,

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<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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.