CnxMutexInterface struct
#include <include/Cnx/sync/Mutex.h>
CnxMutexInterface
is a uniform interface and Trait implementation that all higher-level mutexes (ie not the basic primitives provided in <Cnx/
) meeting Cnx's requirements provide. This interface allows for using the various mutex types provided by Cnx with other facilities like CnxUniqueLock
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)
Unlocks the mutex
__CnxMutexId (*const type_id)(CnxMutexInterface* restrict mutex)
Returns the mutex type ID for the mutex. Used internally by scoped lock guards like `CnxUniqueLock` to identify the concrete type of the mutex