summaryrefslogtreecommitdiff
path: root/libddekit/ddekit/condvar.h
blob: 129a718d0a53645c95b6fa3deb9765d6e83827ad (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef _ddekit_condvar_h
#define _ddekit_condvar_h

/** \file ddekit/condvar.h */
#include "ddekit/lock.h"

struct ddekit_condvar;
typedef struct ddekit_condvar ddekit_condvar_t;

/** Initialize conditional variable.
 *
 * \ingroup DDEKit_synchronization
 */
ddekit_condvar_t * ddekit_condvar_init(void);

/** Uninitialize conditional variable. 
 *
 * \ingroup DDEKit_synchronization
 */
void ddekit_condvar_deinit(ddekit_condvar_t *cvp);

/** Wait on a conditional variable.
 *
 * \ingroup DDEKit_synchronization
 */
void ddekit_condvar_wait(ddekit_condvar_t *cvp, ddekit_lock_t *mp);

/** Wait on a conditional variable at most until a timeout expires.
 *
 * \ingroup DDEKit_synchronization
 *
 * \param cvp    pointer to condvar
 * \param mp     lock
 * \param timo   timeout in ms
 *
 * \return 0     success
 * \return !=0   timeout
 */
int  ddekit_condvar_wait_timed(ddekit_condvar_t *cvp, ddekit_lock_t *mp, int timo);

/** Send signal to the next one waiting for condvar.
 *
 * \ingroup DDEKit_synchronization
 */
void ddekit_condvar_signal(ddekit_condvar_t *cvp);

/** Send signal to all threads waiting for condvar.
 *
 * \ingroup DDEKit_synchronization
 */
void ddekit_condvar_broadcast(ddekit_condvar_t *cvp);

#endif