Lockable

Trait Lockable 

Source
pub trait Lockable {
    type GuardMut<'a>
       where Self: 'a;

    // Required methods
    fn lock(&self) -> Self::GuardMut<'_>;
    fn try_lock(&self) -> Option<Self::GuardMut<'_>>;
    fn unlock(guard: Self::GuardMut<'_>) -> &Self;
}
Expand description

Any mutex object should implement this trait

Required Associated Types§

Source

type GuardMut<'a> where Self: 'a

RAII scoped lock guard type.

Required Methods§

Source

fn lock(&self) -> Self::GuardMut<'_>

Lock self and returns RAII locker guard object.

Source

fn try_lock(&self) -> Option<Self::GuardMut<'_>>

Attempts to acquire this lock.

If the lock could not be acquired at this time, then None is returned. Otherwise, an RAII guard is returned. The lock will be unlocked when the guard is dropped.

Source

fn unlock(guard: Self::GuardMut<'_>) -> &Self

Immediately drops the guard, and consequently unlocks the Lockable object.

The return value is the associated Lockable object of this guard

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Lockable for hala_sync::spin_simple::SpinMutex<T>

Source§

type GuardMut<'a> = SpinMutexGuard<'a, T> where Self: 'a

Source§

impl<T> Lockable for hala_sync::SpinMutex<T>

Source§

type GuardMut<'a> = SpinMutexGuard<'a, T> where Self: 'a