1258945Sroberto/*
2258945Sroberto * Copyright (C) 2004, 2007  Internet Systems Consortium, Inc. ("ISC")
3258945Sroberto * Copyright (C) 1998-2001  Internet Software Consortium.
4258945Sroberto *
5258945Sroberto * Permission to use, copy, modify, and/or distribute this software for any
6258945Sroberto * purpose with or without fee is hereby granted, provided that the above
7258945Sroberto * copyright notice and this permission notice appear in all copies.
8258945Sroberto *
9258945Sroberto * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10258945Sroberto * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11258945Sroberto * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12258945Sroberto * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13258945Sroberto * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14258945Sroberto * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15258945Sroberto * PERFORMANCE OF THIS SOFTWARE.
16258945Sroberto */
17258945Sroberto
18258945Sroberto/* $Id: condition.h,v 1.17 2007/06/18 23:47:49 tbox Exp $ */
19258945Sroberto
20258945Sroberto#ifndef ISC_CONDITION_H
21258945Sroberto#define ISC_CONDITION_H 1
22258945Sroberto
23258945Sroberto#include <windows.h>
24258945Sroberto
25258945Sroberto#include <isc/lang.h>
26258945Sroberto#include <isc/mutex.h>
27258945Sroberto#include <isc/thread.h>
28258945Sroberto#include <isc/types.h>
29258945Sroberto
30258945Srobertotypedef struct isc_condition_thread isc_condition_thread_t;
31258945Sroberto
32258945Srobertostruct isc_condition_thread {
33258945Sroberto	unsigned long				th;
34258945Sroberto	HANDLE					handle[2];
35258945Sroberto	ISC_LINK(isc_condition_thread_t)	link;
36258945Sroberto
37258945Sroberto};
38258945Sroberto
39258945Srobertotypedef struct isc_condition {
40258945Sroberto	HANDLE 		events[2];
41258945Sroberto	unsigned int	waiters;
42258945Sroberto	ISC_LIST(isc_condition_thread_t) threadlist;
43258945Sroberto} isc_condition_t;
44258945Sroberto
45258945SrobertoISC_LANG_BEGINDECLS
46258945Sroberto
47258945Srobertoisc_result_t
48258945Srobertoisc_condition_init(isc_condition_t *);
49258945Sroberto
50258945Srobertoisc_result_t
51258945Srobertoisc_condition_wait(isc_condition_t *, isc_mutex_t *);
52258945Sroberto
53258945Srobertoisc_result_t
54258945Srobertoisc_condition_signal(isc_condition_t *);
55258945Sroberto
56258945Srobertoisc_result_t
57258945Srobertoisc_condition_broadcast(isc_condition_t *);
58258945Sroberto
59258945Srobertoisc_result_t
60258945Srobertoisc_condition_destroy(isc_condition_t *);
61258945Sroberto
62258945Srobertoisc_result_t
63258945Srobertoisc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *);
64258945Sroberto
65258945SrobertoISC_LANG_ENDDECLS
66258945Sroberto
67258945Sroberto#endif /* ISC_CONDITION_H */
68