Annotation of embedaddon/strongswan/src/libstrongswan/threading/rwlock_condvar.h, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (C) 2012 Tobias Brunner
3: * HSR Hochschule fuer Technik Rapperswil
4: *
5: * This program is free software; you can redistribute it and/or modify it
6: * under the terms of the GNU General Public License as published by the
7: * Free Software Foundation; either version 2 of the License, or (at your
8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9: *
10: * This program is distributed in the hope that it will be useful, but
11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13: * for more details.
14: */
15:
16: /**
17: * @defgroup rwlock_condvar rwlock_condvar
18: * @{ @ingroup threading
19: */
20:
21: #ifndef RWLOCK_CONDVAR_H_
22: #define RWLOCK_CONDVAR_H_
23:
24: typedef struct rwlock_condvar_t rwlock_condvar_t;
25:
26: #include "rwlock.h"
27:
28: /**
29: * A special condvar implementation that can be used in conjunction
30: * with rwlock_t (the write lock to be precise).
31: *
32: * @note The implementation does not verify that the current thread actually
33: * holds the write lock and not the read lock, so watch out.
34: */
35: struct rwlock_condvar_t {
36:
37: /**
38: * Wait on a condvar until it gets signalized.
39: *
40: * @param lock lock to release while waiting (write lock)
41: */
42: void (*wait)(rwlock_condvar_t *this, rwlock_t *lock);
43:
44: /**
45: * Wait on a condvar until it gets signalized, or times out.
46: *
47: * @param lock lock to release while waiting (write lock)
48: * @param timeout timeout im ms
49: * @return TRUE if timed out, FALSE otherwise
50: */
51: bool (*timed_wait)(rwlock_condvar_t *this, rwlock_t *lock, u_int timeout);
52:
53: /**
54: * Wait on a condvar until it gets signalized, or times out.
55: *
56: * The passed timeval should be calculated based on the time_monotonic()
57: * function.
58: *
59: * @param lock lock to release while waiting (write lock)
60: * @param tv absolute time until timeout
61: * @return TRUE if timed out, FALSE otherwise
62: */
63: bool (*timed_wait_abs)(rwlock_condvar_t *this, rwlock_t *lock,
64: timeval_t tv);
65:
66: /**
67: * Wake up a single thread in a condvar.
68: */
69: void (*signal)(rwlock_condvar_t *this);
70:
71: /**
72: * Wake up all threads in a condvar.
73: */
74: void (*broadcast)(rwlock_condvar_t *this);
75:
76: /**
77: * Destroy a condvar and free its resources.
78: */
79: void (*destroy)(rwlock_condvar_t *this);
80: };
81:
82: /**
83: * Create a condvar instance.
84: *
85: * @return condvar instance
86: */
87: rwlock_condvar_t *rwlock_condvar_create();
88:
89: #endif /** RWLOCK_CONDVAR_H_ @} */
90:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>