31#ifdef BUILD_ON_WINDOWS
33 EnterCriticalSection(*
lock);
37 LeaveCriticalSection(*
lock);
41 SleepConditionVariableCS(*
cond, *
lock, INFINITE);
44 WakeAllConditionVariable(*
cond);
48 WakeConditionVariable(*
cond);
52 *thread = CreateThread(NULL, 0, fun,
arg, 0, NULL);
56 WaitForSingleObject(thread, INFINITE);
59 return DeleteCriticalSection(*
lock);
62 InitializeCriticalSection(*
lock);
67 InitializeConditionVariable(*
cond);
72 return pthread_mutex_lock(
lock);
75 return pthread_mutex_unlock(
lock);
78 pthread_join(thread, NULL);
84 return pthread_cond_broadcast(
cond);
87 return pthread_cond_signal(
cond);
90 pthread_mutexattr_t attr;
91 pthread_mutexattr_init(&attr);
92 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
93 return pthread_mutex_init(
lock, &attr);
96 pthread_mutex_destroy(
lock);
99 return pthread_cond_init(
cond, NULL);
102 pthread_cond_destroy(
cond);
105 return pthread_create(thread, NULL, fun,
arg);
bool threadpool_add(threadpool_t *p, void(*fun)(void *), void *arg)
static ANN bool gwt_create(gwtthread_t *thread, gwtreturn_t(*fun)(void *), void *arg)
static ANN void gwt_cond_end(gwtcond_t *cond)
static ANN int gwt_cond_ini(gwtcond_t *cond)
pthread_mutex_t gwtlock_t
static ANN int gwt_broadcast(gwtcond_t *cond)
ANN void free_threadpool(threadpool_t *pool)
@ threadpool_thread_failure
@ threadpool_lock_failure
static ANN int gwt_unlock(gwtlock_t *lock)
static ANN void gwt_join(gwtthread_t thread)
static ANN void gwt_lock_end(gwtlock_t *lock)
static ANN int gwt_lock_ini(gwtlock_t *lock)
static ANN int gwt_signal(gwtcond_t *cond)
static ANN void gwt_wait(gwtcond_t *cond, gwtlock_t *lock)
static ANN int gwt_lock(gwtlock_t *lock)
threadpool_t * new_threadpool(const uint32_t thread_count, const uint32_t queue_size)