CnxSharedMutexInterface struct
#include <include/Cnx/sync/SharedMutex.h>
CnxSharedMutexInterface
is a uniform interface and Trait implementation that all higher-level reader-writer mutexes meeting Cnx's requirements provide. This interface allows for using the various reader-writer mutex types provided by Cnx with other facilities like CnxSharedLock
without having to special case on the type(s) of the mutex(es) used.
Functions:
void (*const lock)(CnxMutexInterface* restrict mutex)
Exclusively lock the mutex
bool (*const try_lock)(CnxMutexInterface* restrict mutex)
Attempt to exclusively lock the mutex
bool (*const try_lock_for)(CnxMutexInterface* restrict mutex, CnxDuration duration)
Attempt to exclusively lock the mutex, timeout after `duration` amount of time has passed. Only available if `mutex` is a timed mutex (otherwise this will be `nullptr`).
bool (*const try_lock_until)(CnxMutexInterface* restrict mutex, CnxTimePoint stop_point)
Attempt to exclusively lock the mutex, timeout once the time `stop_point` has occurred. Only available if `mutex` is a timed mutex (otherwise this will be `nullptr`).
void (*const unlock)(CnxMutexInterface* restrict mutex)
Releases the exclusive lock on the mutex
void (*const lock_shared)(CnxMutexInterface* restrict mutex)
Non-exclusively (shared) lock the mutex
bool (*const try_lock_shared)(CnxMutexInterface* restrict mutex)
Attempt to non-exclusively (shared) lock the mutex
bool (*const try_lock_shared_for)(CnxMutexInterface* restrict mutex, CnxDuration duration)
Attempt to non-exclusively (shared) lock the mutex, timeout after `duration` amount of time has passed. Only available if `mutex` is a timed mutex (otherwise this will be `nullptr`).
bool (*const try_lock_shared_until)(CnxMutexInterface* restrict mutex, CnxTimePoint stop_point)
Attempt to non-exclusively (shared) lock the mutex, timeout once the time `stop_point` has occurred. Only available if `mutex` is a timed mutex (otherwise this will be `nullptr`).
void (*const unlock_shared)(CnxMutexInterface* restrict mutex)
Releases a non-exclusive (shared) lock on the mutex -
__CnxMutexId (*const type_id)(CnxMutexInterface* restrict mutex)
Returns the mutex type ID for the mutex. Used internally by scoped lock guards like `CnxSharedLock` to identify the concrete type of the mutex