From 0d1860ef63c2f7962c41ddeba4d71f53c89931a8 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 26 May 2022 12:14:49 +0600 Subject: [PATCH] thread_test_mutex for Unix threads --- src/unix/unix_thread.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/unix/unix_thread.c b/src/unix/unix_thread.c index dc7625e12..5221d90eb 100644 --- a/src/unix/unix_thread.c +++ b/src/unix/unix_thread.c @@ -157,6 +157,18 @@ thread_wait_mutex(mutex_t *_mutex) } +int +thread_test_mutex(mutex_t *_mutex) +{ + if (_mutex == NULL) + return(0); + pt_mutex_t *mutex = (pt_mutex_t *)_mutex; + + return + pthread_mutex_trylock(&mutex->mutex) != 0; +} + + int thread_release_mutex(mutex_t *_mutex) {