8#include "daq/slc/system/Cond.h"
20Cond::Cond(
const Cond& cond)
22 m_cond_t = cond.m_cond_t;
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) {
33 pthread_condattr_destroy(&mattr);
40 if (pthread_cond_signal(&m_cond_t) == 0)
return true;
46 if (pthread_cond_broadcast(&m_cond_t) == 0)
return true;
50bool Cond::wait(
Mutex& mutex)
52 if (pthread_cond_wait(&m_cond_t, &mutex.m_mu) != 0) {
58bool Cond::wait(
Mutex& mutex,
const unsigned int sec,
const unsigned int msec)
61 struct timespec timeout;
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) {
74 if (pthread_cond_destroy(&m_cond_t) == 0)
return true;
Abstract base class for different kinds of events.