xref: /freebsd-src/contrib/ntp/libntp/lib/isc/win32/include/isc/condition.h (revision a466cc55373fc3cf86837f09da729535b57e69a1)
1*a466cc55SCy Schubert /*
2*a466cc55SCy Schubert  * Copyright (C) 2004, 2007  Internet Systems Consortium, Inc. ("ISC")
3*a466cc55SCy Schubert  * Copyright (C) 1998-2001  Internet Software Consortium.
4*a466cc55SCy Schubert  *
5*a466cc55SCy Schubert  * Permission to use, copy, modify, and/or distribute this software for any
6*a466cc55SCy Schubert  * purpose with or without fee is hereby granted, provided that the above
7*a466cc55SCy Schubert  * copyright notice and this permission notice appear in all copies.
8*a466cc55SCy Schubert  *
9*a466cc55SCy Schubert  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10*a466cc55SCy Schubert  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11*a466cc55SCy Schubert  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12*a466cc55SCy Schubert  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13*a466cc55SCy Schubert  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14*a466cc55SCy Schubert  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15*a466cc55SCy Schubert  * PERFORMANCE OF THIS SOFTWARE.
16*a466cc55SCy Schubert  */
17*a466cc55SCy Schubert 
18*a466cc55SCy Schubert /* $Id: condition.h,v 1.17 2007/06/18 23:47:49 tbox Exp $ */
19*a466cc55SCy Schubert 
20*a466cc55SCy Schubert #ifndef ISC_CONDITION_H
21*a466cc55SCy Schubert #define ISC_CONDITION_H 1
22*a466cc55SCy Schubert 
23*a466cc55SCy Schubert #include <windows.h>
24*a466cc55SCy Schubert 
25*a466cc55SCy Schubert #include <isc/lang.h>
26*a466cc55SCy Schubert #include <isc/mutex.h>
27*a466cc55SCy Schubert #include <isc/thread.h>
28*a466cc55SCy Schubert #include <isc/types.h>
29*a466cc55SCy Schubert 
30*a466cc55SCy Schubert typedef struct isc_condition_thread isc_condition_thread_t;
31*a466cc55SCy Schubert 
32*a466cc55SCy Schubert struct isc_condition_thread {
33*a466cc55SCy Schubert 	unsigned long				th;
34*a466cc55SCy Schubert 	HANDLE					handle[2];
35*a466cc55SCy Schubert 	ISC_LINK(isc_condition_thread_t)	link;
36*a466cc55SCy Schubert 
37*a466cc55SCy Schubert };
38*a466cc55SCy Schubert 
39*a466cc55SCy Schubert typedef struct isc_condition {
40*a466cc55SCy Schubert 	HANDLE 		events[2];
41*a466cc55SCy Schubert 	unsigned int	waiters;
42*a466cc55SCy Schubert 	ISC_LIST(isc_condition_thread_t) threadlist;
43*a466cc55SCy Schubert } isc_condition_t;
44*a466cc55SCy Schubert 
45*a466cc55SCy Schubert ISC_LANG_BEGINDECLS
46*a466cc55SCy Schubert 
47*a466cc55SCy Schubert isc_result_t
48*a466cc55SCy Schubert isc_condition_init(isc_condition_t *);
49*a466cc55SCy Schubert 
50*a466cc55SCy Schubert isc_result_t
51*a466cc55SCy Schubert isc_condition_wait(isc_condition_t *, isc_mutex_t *);
52*a466cc55SCy Schubert 
53*a466cc55SCy Schubert isc_result_t
54*a466cc55SCy Schubert isc_condition_signal(isc_condition_t *);
55*a466cc55SCy Schubert 
56*a466cc55SCy Schubert isc_result_t
57*a466cc55SCy Schubert isc_condition_broadcast(isc_condition_t *);
58*a466cc55SCy Schubert 
59*a466cc55SCy Schubert isc_result_t
60*a466cc55SCy Schubert isc_condition_destroy(isc_condition_t *);
61*a466cc55SCy Schubert 
62*a466cc55SCy Schubert isc_result_t
63*a466cc55SCy Schubert isc_condition_waituntil(isc_condition_t *, isc_mutex_t *, isc_time_t *);
64*a466cc55SCy Schubert 
65*a466cc55SCy Schubert ISC_LANG_ENDDECLS
66*a466cc55SCy Schubert 
67*a466cc55SCy Schubert #endif /* ISC_CONDITION_H */
68