pub unsafe trait RawMutex {
    type GuardMarker;

    const INIT: Self;

    // Required methods
    fn lock(&self);
    fn try_lock(&self) -> bool;
    unsafe fn unlock(&self);

    // Provided method
    fn is_locked(&self) -> bool { ... }
}
Expand description

Basic operations for a mutex.

Types implementing this trait can be used by Mutex to form a safe and fully-functioning mutex type.

Safety

Implementations of this trait must ensure that the mutex is actually exclusive: a lock can’t be acquired while the mutex is already locked.

Required Associated Types§

type GuardMarker

Marker type which determines whether a lock guard should be Send. Use one of the GuardSend or GuardNoSend helper types here.

Required Associated Constants§

const INIT: Self

Initial value for an unlocked mutex.

Required Methods§

fn lock(&self)

Acquires this mutex, blocking the current thread until it is able to do so.

fn try_lock(&self) -> bool

Attempts to acquire this mutex without blocking. Returns true if the lock was successfully acquired and false otherwise.

unsafe fn unlock(&self)

Unlocks this mutex.

Safety

This method may only be called if the mutex is held in the current context, i.e. it must be paired with a successful call to lock, try_lock, try_lock_for or try_lock_until.

Provided Methods§

fn is_locked(&self) -> bool

Checks whether the mutex is currently locked.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl RawMutex for RawFairMutex

source§

impl RawMutex for RawMutex

source§

const INIT: RawMutex = _

§

type GuardMarker = GuardNoSend

source§

fn lock(&self)

source§

fn try_lock(&self) -> bool

source§

unsafe fn unlock(&self)

source§

fn is_locked(&self) -> bool

Implementors§

source§

impl RawMutex for holochain::prelude::dependencies::kitsune_p2p_types::dependencies::lair_keystore_api::dependencies::parking_lot::RawFairMutex

source§

impl RawMutex for holochain::prelude::dependencies::kitsune_p2p_types::dependencies::lair_keystore_api::dependencies::parking_lot::RawMutex