Skip to main content

RawLock

Trait RawLock 

Source
pub trait RawLock {
    type LockEntry: Default;
    type GuardState: Default + Copy;

    // Required methods
    fn init() -> impl PinInit<Self>
       where Self: Sized;
    fn as_mut_ptr(&self) -> *mut c_void;
    unsafe fn acquire(
        &self,
        lcid: *mut c_void,
        entry: *mut Self::LockEntry,
    ) -> Self::GuardState;
    unsafe fn release(
        &self,
        entry: *mut Self::LockEntry,
        state: Self::GuardState,
    );
}
Expand description

Trait defining a raw, un-instrumented synchronization lock abstraction.

Implementors of RawLock supply the platform-specific lock storage, in-place pinning initialization logic, and raw synchronization entry points for lock validation systems.

Required Associated Types§

Source

type LockEntry: Default

Opaque stack entry storage type used by the lock validation loop detector (e.g. LockDep).

Source

type GuardState: Default + Copy

State returned from lock acquisition and subsequently passed to lock release.

Required Methods§

Source

fn init() -> impl PinInit<Self>
where Self: Sized,

Returns a PinInit block to initialize the raw mutex in-place.

Source

fn as_mut_ptr(&self) -> *mut c_void

Convert the raw mutex reference to a standard c_void pointer for FFI.

Source

unsafe fn acquire( &self, lcid: *mut c_void, entry: *mut Self::LockEntry, ) -> Self::GuardState

Acquires the raw synchronization lock under a type-level lock class.

§Safety
  1. The lcid pointer must point to a valid dynamic LockClassId if not null (used for LockDep).
  2. The entry pointer must point to a valid, exclusive, stack-allocated LockEntry slot which will be registered in the thread’s active list.
  3. The caller must ensure that the entry memory remains pinned on the stack and is not dropped or moved until the matching release call completes.
Source

unsafe fn release(&self, entry: *mut Self::LockEntry, state: Self::GuardState)

Releases the raw synchronization lock, restoring the state.

§Safety
  1. The entry pointer must match the exact same stack slot pointer passed to the corresponding acquire call.
  2. The state parameter must match the exact same state value returned by the corresponding acquire call.
  3. The caller must guarantee that the current thread actually holds this lock (i.e. we are releasing a lock we currently own).

Implementations on Foreign Types§

Source§

impl RawLock for RawSyncMutex

Source§

type LockEntry = ()

Source§

type GuardState = ()

Source§

fn init() -> impl PinInit<RawSyncMutex>

Source§

fn as_mut_ptr(&self) -> *mut c_void

Source§

unsafe fn acquire( &self, _lcid: *mut c_void, _entry: *mut <RawSyncMutex as RawLock>::LockEntry, ) -> <RawSyncMutex as RawLock>::GuardState

Source§

unsafe fn release( &self, _entry: *mut <RawSyncMutex as RawLock>::LockEntry, _state: <RawSyncMutex as RawLock>::GuardState, )

Implementors§