condition.h 761 Bytes
Newer Older
Bob Halley's avatar
add  
Bob Halley committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

#ifndef CONDITION_H
#define CONDITION_H 1

#ifdef MULTITHREADED

#include <pthread.h>
#include <isc/assertions.h>

typedef pthread_cond_t			os_condition_t;
#define OS_CONDITION_INITIALIZER	PTHREAD_COND_INITIALIZER

#define os_condition_init(cp)		INSIST(pthread_cond_init((cp), NULL) \
					       == 0)
#define os_condition_wait(cp, mp)	INSIST(pthread_cond_wait((cp), (mp)) \
					       == 0)
#define os_condition_signal(cp)		INSIST(pthread_cond_signal((cp)) == 0)
#define os_condition_broadcast(cp)	INSIST(pthread_cond_broadcast((cp)) \
					       == 0)
#define os_condition_destroy(cp)	INSIST(pthread_cond_destroy((cp)) \
					       == 0)

#else

Bob Halley's avatar
update  
Bob Halley committed
25
#error Condition variables are not meaningful for a non-threaded program.
Bob Halley's avatar
add  
Bob Halley committed
26 27 28 29

#endif

#endif /* CONDITION_H */