SyncHandlerAPI

Trait SyncHandlerAPI 

Source
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§

Source

type Handler

Type of the sync handler.

Required Methods§

Source

fn to_interface(&self) -> NonNullConst<SyncHandlerInterface>

Fetches a pointer that can be used with the interface.

Source

unsafe fn from_interface( handler: NonNullConst<SyncHandlerInterface>, ) -> Self::Handler

Construct a new instance with the pointer.

§Safety

This function should not be used directly.

Source

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.

Source

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.

Source

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.

Implementors§