Struct concurrency_traits::mutex::CustomMutex[][src]

pub struct CustomMutex<T, M: ?Sized> { /* fields omitted */ }
Expand description

A Mutex based on a given RawTryMutex

Implementations

impl<T, M> CustomMutex<T, M>[src]

pub const fn from_raw(raw_mutex: M, data: T) -> Self[src]

Creates a new CustomMutex with a RawMutex

pub fn new(data: T) -> Self where
    M: Default
[src]

Creates a new mutex with a default raw

Trait Implementations

impl<'a, T, M> AsyncMutex<'a> for CustomMutex<T, M> where
    T: 'a + Send,
    M: RawAsyncMutex + 'a + Send + Sync
[src]

fn lock_async<'async_trait>(
    &'a self
) -> Pin<Box<dyn Future<Output = Self::Guard> + Send + 'async_trait>> where
    'a: 'async_trait,
    Self: 'async_trait, 
[src]

Locks the mutex asynchronously, returning a future with the guard.

impl<'a, T, M> AsyncTimeoutMutex<'a> for CustomMutex<T, M> where
    T: 'a + Send,
    M: RawAsyncTimeoutMutex + 'a + Send + Sync
[src]

fn lock_timeout_async<'async_trait>(
    &'a self,
    timeout: Duration
) -> Pin<Box<dyn Future<Output = Option<Self::Guard>> + Send + 'async_trait>> where
    'a: 'async_trait,
    Self: 'async_trait, 
[src]

Locks the mutex asynchronously with a timeout.

impl<T: Debug, M: Debug + ?Sized> Debug for CustomMutex<T, M>[src]

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

Formats the value using the given formatter. Read more

impl<T, M> Default for CustomMutex<T, M> where
    T: Default,
    M: Default
[src]

fn default() -> Self[src]

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

impl<T, M> From<T> for CustomMutex<T, M> where
    M: Default
[src]

fn from(from: T) -> Self[src]

Performs the conversion.

impl<'a, T, M> Mutex<'a> for CustomMutex<T, M> where
    T: 'a,
    M: RawMutex + 'a, 
[src]

fn lock(&'a self) -> Self::Guard[src]

Locks the mutex, blocking until successful

impl<'a, T, M> MutexSized<'a> for CustomMutex<T, M> where
    T: 'a,
    M: RawMutex + 'a, 
[src]

fn lock_func<O>(&'a self, func: impl FnOnce(&mut Self::Item) -> O) -> O[src]

Runs the function on the value in the mutex. Read more

impl<'a, T, M> TimeoutMutex<'a> for CustomMutex<T, M> where
    T: 'a,
    M: RawTimeoutMutex + 'a, 
[src]

fn lock_timeout(&'a self, timeout: Duration) -> Option<Self::Guard>[src]

Locks the mutex blocking for timeout or until locked

impl<'a, T, M> TimeoutMutexSized<'a> for CustomMutex<T, M> where
    T: 'a,
    M: RawTimeoutMutex + 'a, 
[src]

fn lock_timeout_func<O>(
    &'a self,
    timeout: Duration,
    func: impl FnOnce(Option<&mut Self::Item>) -> O
) -> O
[src]

Attempts to lock the mutex before timeout has passed and runs func on the result Read more

impl<'a, T, M> TryMutex<'a> for CustomMutex<T, M> where
    T: 'a,
    M: RawTryMutex + 'a, 
[src]

type Item = T

The item stored in the mutex

type Guard = CustomMutexGuard<'a, T, M>

The guard for the mutex

fn try_lock(&'a self) -> Option<Self::Guard>[src]

Tries to lock the mutex, returning None if not possible.

impl<'a, T, M> TryMutexSized<'a> for CustomMutex<T, M> where
    T: 'a,
    M: RawTryMutex + 'a, 
[src]

fn try_lock_func<O>(
    &'a self,
    func: impl FnOnce(Option<&mut Self::Item>) -> O
) -> O
[src]

Runs the function the value in the mutex if available immediately. Read more

impl<T, M> Sync for CustomMutex<T, M> where
    T: Send,
    M: Sync
[src]

Auto Trait Implementations

impl<T, M> !RefUnwindSafe for CustomMutex<T, M>

impl<T, M: ?Sized> Send for CustomMutex<T, M> where
    M: Send,
    T: Send

impl<T, M: ?Sized> Unpin for CustomMutex<T, M> where
    M: Unpin,
    T: Unpin

impl<T, M: ?Sized> UnwindSafe for CustomMutex<T, M> where
    M: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<!> for T[src]

pub fn from(t: !) -> T[src]

Performs the conversion.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.