pub trait SyncHandlerAPI<'a> {
type Handler;
// Required methods
fn to_interface(&self) -> NonNullConst<SyncHandlerInterface>;
unsafe fn from_interface(
handler: NonNullConst<SyncHandlerInterface>,
) -> Self::Handler;
unsafe fn lock(&self);
unsafe fn try_lock(&self) -> bool;
unsafe fn unlock(&self);
}Expand description
The API of a sync handler.
Required Associated Types§
Required Methods§
Sourcefn to_interface(&self) -> NonNullConst<SyncHandlerInterface>
fn to_interface(&self) -> NonNullConst<SyncHandlerInterface>
Fetches a pointer that can be used with the interface.
Sourceunsafe fn from_interface(
handler: NonNullConst<SyncHandlerInterface>,
) -> Self::Handler
unsafe fn from_interface( handler: NonNullConst<SyncHandlerInterface>, ) -> Self::Handler
Sourceunsafe fn lock(&self)
unsafe fn lock(&self)
Locks the synchronisation handler.
The calling thread is stalled until the lock can be acquired. Only one thread can hold the lock at a time.
§Safety
The function crosses the ffi boundary. Direct usage of a SyncHandlerAPI may break some invariants of the sys api, if not handled with care.
Sourceunsafe fn try_lock(&self) -> bool
unsafe fn try_lock(&self) -> bool
Tries to lock the synchronisation handler.
The function fails if another thread already holds the lock.
§Return
true on success and false otherwise.
§Safety
The function crosses the ffi boundary. Direct usage of a SyncHandlerAPI may break some invariants of the sys api, if not handled with care.
Sourceunsafe fn unlock(&self)
unsafe fn unlock(&self)
Unlocks the synchronisation handler.
§Safety
The function crosses the ffi boundary. Trying to call this function without prior locking is undefined behaviour. Direct usage of a SyncHandlerAPI may break some invariants of the sys api, if not handled with care.
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.