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§
Sourcetype LockEntry: Default
type LockEntry: Default
Opaque stack entry storage type used by the lock validation loop detector (e.g. LockDep).
Sourcetype GuardState: Default + Copy
type GuardState: Default + Copy
State returned from lock acquisition and subsequently passed to lock release.
Required Methods§
Sourcefn init() -> impl PinInit<Self>where
Self: Sized,
fn init() -> impl PinInit<Self>where
Self: Sized,
Returns a PinInit block to initialize the raw mutex in-place.
Sourcefn as_mut_ptr(&self) -> *mut c_void
fn as_mut_ptr(&self) -> *mut c_void
Convert the raw mutex reference to a standard c_void pointer for FFI.
Sourceunsafe fn acquire(
&self,
lcid: *mut c_void,
entry: *mut Self::LockEntry,
) -> Self::GuardState
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
- The
lcidpointer must point to a valid dynamicLockClassIdif not null (used for LockDep). - The
entrypointer must point to a valid, exclusive, stack-allocatedLockEntryslot which will be registered in the thread’s active list. - The caller must ensure that the
entrymemory remains pinned on the stack and is not dropped or moved until the matchingreleasecall completes.
Sourceunsafe fn release(&self, entry: *mut Self::LockEntry, state: Self::GuardState)
unsafe fn release(&self, entry: *mut Self::LockEntry, state: Self::GuardState)
Releases the raw synchronization lock, restoring the state.
§Safety
- The
entrypointer must match the exact same stack slot pointer passed to the correspondingacquirecall. - The
stateparameter must match the exact same state value returned by the correspondingacquirecall. - The caller must guarantee that the current thread actually holds this lock (i.e. we are releasing a lock we currently own).