Skip to content

Commit 771ab9c

Browse files
committed
feat(#612): Add hmutex_trylock
1 parent 4142980 commit 771ab9c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

base/hmutex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ BEGIN_EXTERN_C
1212
#define hmutex_init InitializeCriticalSection
1313
#define hmutex_destroy DeleteCriticalSection
1414
#define hmutex_lock EnterCriticalSection
15+
#define hmutex_trylock TryEnterCriticalSection
1516
#define hmutex_unlock LeaveCriticalSection
1617

1718
#define hrecursive_mutex_t CRITICAL_SECTION
@@ -79,6 +80,7 @@ static inline void honce(honce_t* once, honce_fn fn) {
7980
#define hmutex_init(pmutex) pthread_mutex_init(pmutex, NULL)
8081
#define hmutex_destroy pthread_mutex_destroy
8182
#define hmutex_lock pthread_mutex_lock
83+
#define hmutex_trylock(pmutex) (pthread_mutex_trylock(pmutex) == 0)
8284
#define hmutex_unlock pthread_mutex_unlock
8385

8486
#define hrecursive_mutex_t pthread_mutex_t

0 commit comments

Comments
 (0)