summaryrefslogtreecommitdiff
path: root/source/kit/condition_variable.h
blob: 0e4630dc23c12a9fe7b3a743d7c51f3c362c6c82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef KIT_CONDITION_VARIABLE_H
#define KIT_CONDITION_VARIABLE_H

#ifndef KIT_DISABLE_SYSTEM_THREADS
#  include "mutex.h"

#  ifdef __cplusplus
extern "C" {
#  endif

#  if defined(_WIN32) && !defined(__CYGWIN__)
typedef struct {
  void *Ptr;
} cnd_t;

typedef struct {
  volatile uintptr_t status;
} once_flag;
#  else
typedef pthread_cond_t cnd_t;
typedef pthread_once_t once_flag;
#  endif

void call_once(once_flag *, void (*)(void));
int  cnd_broadcast(cnd_t *);
void cnd_destroy(cnd_t *);
int  cnd_init(cnd_t *);
int  cnd_signal(cnd_t *);
int  cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict mtx_,
                   const struct timespec *__restrict);
int  cnd_wait(cnd_t *, mtx_t *mtx_);

#  ifdef __cplusplus
}
#  endif

#endif

#endif