Fawkes API Fawkes Development Version
wait_condition.h
1
2/***************************************************************************
3 * wait_condition.h - condition variable implementation
4 *
5 * Created: Thu Sep 14 21:34:58 2006
6 * Copyright 2006-2009 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _CORE_THREADING_WAIT_CONDITION_H_
25#define _CORE_THREADING_WAIT_CONDITION_H_
26
27namespace fawkes {
28
29class WaitConditionData;
30class Mutex;
31
32/// @cond INTERNALS
33void cleanup_mutex(void *);
34/// @endcond
35
37{
38public:
39 WaitCondition(Mutex *mutex = 0);
41
42 void wait();
43 bool abstimed_wait(long int sec, long int nanosec);
44 bool reltimed_wait(unsigned int sec, unsigned int nanosec);
45
46 void wake_one();
47 void wake_all();
48
49private:
50 WaitConditionData *cond_data_;
51 Mutex * mutex_;
52 bool own_mutex_;
53};
54
55} // end namespace fawkes
56
57#endif
Mutex mutual exclusion lock.
Definition: mutex.h:33
Wait until a given condition holds.
void wait()
Wait for the condition forever.
void wake_one()
Wake another thread waiting for this condition.
WaitCondition(Mutex *mutex=0)
Constructor.
void wake_all()
Wake up all waiting threads.
bool reltimed_wait(unsigned int sec, unsigned int nanosec)
Wait with relative timeout.
bool abstimed_wait(long int sec, long int nanosec)
Wait with absolute timeout.
Fawkes library namespace.