21 pthread_mutexattr_t attr;
22 pthread_mutexattr_init(&attr);
23 #if !defined(__GLIBC__) || __USE_UNIX98__
24 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
26 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
28 pthread_mutex_init(&thl->
lock, &attr);
30 pthread_mutex_init(&thl->
lock,
NULL);
35 InitializeCriticalSection(&thl->
lock);
48 pthread_mutex_lock(&thl->lock);
50 EnterCriticalSection(&thl->lock);
64 return !pthread_mutex_trylock(&thl->lock);
66 return TryEnterCriticalSection(&thl->lock);
78 pthread_mutex_unlock(&thl->lock);
80 LeaveCriticalSection(&thl->lock);
94 pthread_mutex_destroy(&thl->lock);
96 DeleteCriticalSection(&thl->lock);
RZ_API void Ht_() free(HtName_(Ht) *ht)
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_API void rz_th_lock_leave(RZ_NONNULL RzThreadLock *thl)
Releases a RzThreadLock structure.
RZ_API void rz_th_lock_free(RZ_NULLABLE RzThreadLock *thl)
Frees a RzThreadLock structure.
RZ_API RZ_OWN RzThreadLock * rz_th_lock_new(bool recursive)
Allocates and initialize a RzThreadLock structure.
RZ_API bool rz_th_lock_tryenter(RZ_NONNULL RzThreadLock *thl)
Tries to acquire a RzThreadLock structure.
RZ_API void rz_th_lock_enter(RZ_NONNULL RzThreadLock *thl)
Acquires a RzThreadLock structure.