8#include "daq/slc/system/Cond.h"
20Cond::Cond(
const Cond& cond) : m_cond_t(cond.m_cond_t)
26 pthread_condattr_t mattr;
27 pthread_condattr_init(&mattr);
28 pthread_condattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED);
29 if (pthread_cond_init(&m_cond_t, &mattr) != 0) {
32 pthread_condattr_destroy(&mattr);
39 if (pthread_cond_signal(&m_cond_t) == 0)
return true;
45 if (pthread_cond_broadcast(&m_cond_t) == 0)
return true;
49bool Cond::wait(
Mutex& mutex)
51 if (pthread_cond_wait(&m_cond_t, &mutex.m_mu) != 0) {
57bool Cond::wait(
Mutex& mutex,
const unsigned int sec,
const unsigned int msec)
60 struct timespec timeout;
62 gettimeofday(&now, NULL);
63 timeout.tv_sec = now.tv_sec + sec;
64 timeout.tv_nsec = now.tv_usec * 1000 + msec;
65 if (pthread_cond_timedwait(&m_cond_t, &mutex.m_mu, &timeout) != 0) {
73 if (pthread_cond_destroy(&m_cond_t) == 0)
return true;
Abstract base class for different kinds of events.