summaryrefslogtreecommitdiffstats
path: root/src/thread.h
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-06-20 01:56:35 +0200
committerGravatar Nikias Bassen2021-06-20 01:56:35 +0200
commitcb50087482cf5a4239ad9c96b7157c45eac12876 (patch)
tree1d60de827e4d9c08d7f51f16480d4583ee45ad25 /src/thread.h
parenteb787a10f06e4470134cff33a81bb872e4268bfa (diff)
downloadlibirecovery-cb50087482cf5a4239ad9c96b7157c45eac12876.tar.gz
libirecovery-cb50087482cf5a4239ad9c96b7157c45eac12876.tar.bz2
thread: Add condition variable support
Diffstat (limited to 'src/thread.h')
-rw-r--r--src/thread.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/thread.h b/src/thread.h
index 23e4510..2aadc6e 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -28,6 +28,9 @@
#include <windows.h>
typedef HANDLE THREAD_T;
typedef CRITICAL_SECTION mutex_t;
+typedef struct {
+ HANDLE sem;
+} cond_t;
typedef volatile struct {
LONG lock;
int state;
@@ -38,8 +41,10 @@ typedef volatile struct {
#else
#include <pthread.h>
#include <signal.h>
+#include <sys/time.h>
typedef pthread_t THREAD_T;
typedef pthread_mutex_t mutex_t;
+typedef pthread_cond_t cond_t;
typedef pthread_once_t thread_once_t;
#define THREAD_ONCE_INIT PTHREAD_ONCE_INIT
#define THREAD_ID pthread_self()
@@ -73,4 +78,10 @@ void mutex_unlock(mutex_t* mutex);
void thread_once(thread_once_t *once_control, void (*init_routine)(void));
+void cond_init(cond_t* cond);
+void cond_destroy(cond_t* cond);
+int cond_signal(cond_t* cond);
+int cond_wait(cond_t* cond, mutex_t* mutex);
+int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms);
+
#endif