MeVisLab Toolbox Reference
mlWaitCondition.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_WAIT_CONDITION_H
14 #define ML_WAIT_CONDITION_H
15 
18 
19 #include "mlUtilsSystem.h"
20 
21 #include "mlMutex.h"
22 
23 ML_UTILS_START_NAMESPACE
24 
25 //--------------------------------------------------------------------
28 
44 //--------------------------------------------------------------------
46 {
47 public:
49 
50  //--------------------------------------------------------------------
53  //--------------------------------------------------------------------
54  void wait(Lock& lock)
55  {
56  _condition.wait(lock);
57  }
58 
59  //--------------------------------------------------------------------
62  //--------------------------------------------------------------------
63  template<typename duration_type> bool wait(Lock& lock, duration_type duration)
64  {
65  return _condition.timed_wait(lock, duration);
66  }
67 
68  //--------------------------------------------------------------------
70  //--------------------------------------------------------------------
71  void notifyAll()
72  {
73  _condition.notify_all();
74  }
75 
76  //--------------------------------------------------------------------
78  //--------------------------------------------------------------------
79  void notifyOne()
80  {
81  _condition.notify_one();
82  }
83 
84 private:
86  boost::condition _condition;
87 };
88 
89 ML_UTILS_END_NAMESPACE
90 
91 #endif // __mlWaitCondition_H
WaitCondition implements a wait condition for thread synchronization.
void wait(Lock &lock)
Waits for the condition, given a locked non-recursive mutex.
void notifyOne()
Notifies one waiting thread.
void notifyAll()
Notifies all waiting threads.
bool wait(Lock &lock, duration_type duration)
Waits for the condition, given a locked non-recursive mutex.
boost::mutex::scoped_lock Lock
Defines a lock for locking a non-recursive mutex.
Definition: mlMutex.h:41