diff options
author | James Almer <jamrial@gmail.com> | 2018-09-30 01:57:09 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2018-09-30 01:59:50 +0300 |
commit | 1c9c2534569fc9c4c9d68cbf23e86273619ecc59 (patch) | |
tree | 8dd8c5c3d3f6056935cb1aefb8470b4bd68a956d /src/thread.h | |
parent | fac06ece700461038336b78d91202096cc12cb38 (diff) |
thread: switch mutex wrappers to SRW locks
Diffstat (limited to 'src/thread.h')
-rw-r--r-- | src/thread.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/thread.h b/src/thread.h index cfdf4a0..4c04687 100644 --- a/src/thread.h +++ b/src/thread.h @@ -34,7 +34,7 @@ #define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT -typedef CRITICAL_SECTION pthread_mutex_t; +typedef SRWLOCK pthread_mutex_t; typedef CONDITION_VARIABLE pthread_cond_t; typedef INIT_ONCE pthread_once_t; typedef void *pthread_t; @@ -52,19 +52,19 @@ static inline void pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr) { (void)attr; - InitializeCriticalSection(mutex); + InitializeSRWLock(mutex); } static inline void pthread_mutex_destroy(pthread_mutex_t* mutex) { - DeleteCriticalSection(mutex); + (void)mutex; } static inline void pthread_mutex_lock(pthread_mutex_t* mutex) { - EnterCriticalSection(mutex); + AcquireSRWLockExclusive(mutex); } static inline void pthread_mutex_unlock(pthread_mutex_t* mutex) { - LeaveCriticalSection(mutex); + ReleaseSRWLockExclusive(mutex); } static inline void pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) { @@ -77,7 +77,7 @@ static inline void pthread_cond_destroy(pthread_cond_t* cond) { } static inline void pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) { - SleepConditionVariableCS(cond, mutex, INFINITE); + SleepConditionVariableSRW(cond, mutex, INFINITE, 0); } static inline void pthread_cond_signal(pthread_cond_t* cond) { |