Implement WinNT condition variables, add semaphors
This commit is contained in:
@@ -8,6 +8,11 @@ struct bh_mutex_s
|
||||
void *handle;
|
||||
};
|
||||
|
||||
struct bh_semaphore_s
|
||||
{
|
||||
void *handle;
|
||||
}:
|
||||
|
||||
struct bh_cond_s
|
||||
{
|
||||
void *handle;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
struct bh_thread_s
|
||||
{
|
||||
@@ -11,6 +12,11 @@ struct bh_mutex_s
|
||||
pthread_mutex_t handle;
|
||||
};
|
||||
|
||||
struct bh_semaphore_s
|
||||
{
|
||||
sem_t handle;
|
||||
};
|
||||
|
||||
struct bh_cond_s
|
||||
{
|
||||
pthread_cond_t handle;
|
||||
@@ -22,6 +28,10 @@ int bh_thread_init(bh_thread_t *thread,
|
||||
int bh_mutex_init(bh_mutex_t *mutex);
|
||||
void bh_mutex_destroy(bh_mutex_t *mutex);
|
||||
|
||||
int bh_semaphore_init(bh_semaphore_t *semaphore,
|
||||
int count);
|
||||
void bh_semaphore_destroy(bh_semaphore_t *semaphore);
|
||||
|
||||
int bh_cond_init(bh_cond_t *cond);
|
||||
void bh_cond_destroy(bh_cond_t *cond);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ struct bh_thread_s
|
||||
int allocated;
|
||||
};
|
||||
|
||||
struct bh_thread_data_s
|
||||
typedef struct bh_thread_data_s
|
||||
{
|
||||
bh_task_t *task;
|
||||
bh_thread_end_cb_t end;
|
||||
@@ -18,14 +18,26 @@ struct bh_mutex_s
|
||||
CRITICAL_SECTION handle;
|
||||
};
|
||||
|
||||
struct bh_semaphore_s
|
||||
{
|
||||
HANDLE handle;
|
||||
};
|
||||
|
||||
#if WINVER >= _WIN32_WINNT_VISTA
|
||||
struct bh_cond_s
|
||||
{
|
||||
CRITICAL_SECTION lock;
|
||||
HANDLE wait;
|
||||
HANDLE done;
|
||||
CONDITION_VARIABLE handle;
|
||||
};
|
||||
#else
|
||||
struct bh_cond_s
|
||||
{
|
||||
bh_mutex_t lock;
|
||||
bh_semaphore_t wait;
|
||||
bh_semaphore_t done;
|
||||
int waiting;
|
||||
int signals;
|
||||
};
|
||||
#endif
|
||||
|
||||
int bh_thread_init_base(bh_thread_t *thread,
|
||||
bh_task_t *task,
|
||||
@@ -38,6 +50,10 @@ int bh_thread_init_base(bh_thread_t *thread,
|
||||
int bh_mutex_init(bh_mutex_t *mutex);
|
||||
void bh_mutex_destroy(bh_mutex_t *mutex);
|
||||
|
||||
int bh_semaphore_init(bh_semaphore_t *semaphore,
|
||||
int count);
|
||||
void bh_semaphore_destroy(bh_semaphore_t *semaphore);
|
||||
|
||||
int bh_cond_init(bh_cond_t *cond);
|
||||
void bh_cond_destroy(bh_cond_t *cond);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user