posix/coil/Condition.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef COIL_CONDITION_H
21 #define COIL_CONDITION_H
22 
23 #include <pthread.h>
24 #include <algorithm>
25 #include <ctime>
26 
27 
28 namespace coil
29 {
43  template <class M>
44  class Condition
45  {
46  public:
47 
63  Condition(M& mutex)
64  : m_mutex(mutex)
65  {
67  }
68 
85  {
86  ::pthread_cond_destroy(&m_cond);
87  }
88 
104  inline void signal()
105  {
107  }
108 
124  inline void broadcast()
125  {
127  }
128 
148  bool wait()
149  {
150  return 0 == ::pthread_cond_wait(&m_cond, &m_mutex.mutex_);
151  }
152 
178  bool wait(long second, long nano_second = 0)
179  {
180  timespec abstime;
181  abstime.tv_sec = std::time(0) + second;
182  abstime.tv_nsec = nano_second;
183  return 0 == ::pthread_cond_timedwait(&m_cond, &m_mutex.mutex_, &abstime);
184  }
185 
186  private:
187  Condition(const M&);
188  Condition& operator=(const M &);
191  };
192 };
193 #endif // COIL_CONDITION_H
int pthread_cond_broadcast(pthread_cond_t *cv)
Resume of all the thread practice.
int pthread_cond_wait(coil::pthread_cond_t *cv, coil::Mutex *external_mutex, DWORD aMilliSecond)
Wait of the thread practice.
ACE_thread_mutex_t mutex_
~Condition()
Destructor.
Condition(M &mutex)
Constructor.
Condition & operator=(const Mutex &)
void broadcast()
Resume of all the thread practice.
Condition(Mutex &mutex)
int pthread_cond_signal(pthread_cond_t *cv)
Resume of the thread practice.
static int pthread_cond_init(pthread_cond_t *cv)
bool wait(long second, long nano_second=0)
Thread practice wait of set time.
pthread_cond_t m_cond
void signal()
Resume of the thread practice.
Common Object Interface Layer.
bool wait()
Wait of the thread practice.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:57