Definition at line 19 of file Cond.h.
◆ Cond() [1/2]
◆ Cond() [2/2]
Definition at line 20 of file Cond.cc.
21{
22 m_cond_t = cond.m_cond_t;
23}
◆ ~Cond()
◆ broadcast()
Definition at line 44 of file Cond.cc.
45{
46 if (pthread_cond_broadcast(&m_cond_t) == 0) return true;
47 else return false;
48}
◆ destroy()
Definition at line 72 of file Cond.cc.
73{
74 if (pthread_cond_destroy(&m_cond_t) == 0) return true;
75 else return false;
76}
◆ init()
Definition at line 25 of file Cond.cc.
26{
27 pthread_condattr_t mattr;
28 pthread_condattr_init(&mattr);
29 pthread_condattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
30 if (pthread_cond_init(&m_cond_t, &mattr) != 0) {
31 return false;
32 }
33 pthread_condattr_destroy(&mattr);
34
35 return true;
36}
◆ signal()
Definition at line 38 of file Cond.cc.
39{
40 if (pthread_cond_signal(&m_cond_t) == 0) return true;
41 else return false;
42}
◆ wait() [1/2]
bool wait |
( |
Mutex & |
mutex | ) |
|
Definition at line 50 of file Cond.cc.
51{
52 if (pthread_cond_wait(&m_cond_t, &mutex.m_mu) != 0) {
53 return false;
54 }
55 return true;
56}
◆ wait() [2/2]
bool wait |
( |
Mutex & |
mutex, |
|
|
const unsigned int |
sec, |
|
|
const unsigned int |
msec = 0 |
|
) |
| |
Definition at line 58 of file Cond.cc.
59{
60 struct timeval now;
61 struct timespec timeout;
62
63 gettimeofday(&now, NULL);
64 timeout.tv_sec = now.tv_sec + sec;
65 timeout.tv_nsec = now.tv_usec * 1000 + msec;
66 if (pthread_cond_timedwait(&m_cond_t, &mutex.m_mu, &timeout) != 0) {
67 return false;
68 }
69 return true;
70}
◆ m_cond_t
The documentation for this class was generated from the following files: