forked from gphilippot/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvcond.h
37 lines (29 loc) · 838 Bytes
/
svcond.h
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
#ifndef MBA_SVCOND_H
#define MBA_SVCOND_H
/* svcond - POSIX-like condition variables implemented using SysV semaphores
* Algorithm by Alexander Terekhov and Louis Thomas.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <mba/svsem.h>
#include <mba/pool.h>
typedef struct {
struct pool *sempool;
svsem_t *blocked_lock;
svsem_t *block_queue;
svsem_t *unblock_lock;
int waiters_blocked;
int waiters_to_unblock;
} svcond_t;
int svcond_create(svcond_t *cond, struct pool *sempool);
int svcond_destroy(svcond_t *cond);
int svcond_pool_create(struct pool *p, unsigned int max_size, struct allocator *al);
int svcond_pool_destroy(struct pool *p);
int svcond_wait(svcond_t *cond, svsem_t *lock);
int svcond_broadcast(svcond_t *cond);
int svcond_signal(svcond_t *cond);
#ifdef __cplusplus
}
#endif
#endif /* MBA_SVCOND_H */