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 
27 namespace fawkes {
28 
29 class WaitConditionData;
30 class Mutex;
31 
32 /// @cond INTERNALS
33 void cleanup_mutex(void *);
34 /// @endcond
35 
37 {
38 public:
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 
49 private:
50  WaitConditionData *cond_data_;
51  Mutex * mutex_;
52  bool own_mutex_;
53 };
54 
55 } // end namespace fawkes
56 
57 #endif
fawkes::Mutex
Mutex mutual exclusion lock.
Definition: mutex.h:33
fawkes::WaitCondition
Wait until a given condition holds.
Definition: wait_condition.h:37
fawkes::WaitCondition::wait
void wait()
Wait for the condition forever.
Definition: wait_condition.cpp:139
fawkes::WaitCondition::abstimed_wait
bool abstimed_wait(long int sec, long int nanosec)
Wait with absolute timeout.
Definition: wait_condition.cpp:169
fawkes::WaitCondition::~WaitCondition
~WaitCondition()
Destructor.
Definition: wait_condition.cpp:123
fawkes
Fawkes library namespace.
fawkes::WaitCondition::reltimed_wait
bool reltimed_wait(unsigned int sec, unsigned int nanosec)
Wait with relative timeout.
Definition: wait_condition.cpp:206
fawkes::WaitCondition::wake_all
void wake_all()
Wake up all waiting threads.
Definition: wait_condition.cpp:287
fawkes::WaitCondition::wake_one
void wake_one()
Wake another thread waiting for this condition.
Definition: wait_condition.cpp:267
fawkes::WaitCondition::WaitCondition
WaitCondition(Mutex *mutex=0)
Constructor.
Definition: wait_condition.cpp:109