8#include "daq/slc/system/MCond.h"
16MCond::MCond(
const MCond& cond)
21MCond::MCond(
void* addr)
23 set((pthread_cond_t*)addr);
28bool MCond::init(
void* addr)
37 pthread_condattr_t attr;
38 pthread_condattr_init(&attr);
39 pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
40 pthread_cond_init(m_cond, &attr);
41 pthread_condattr_destroy(&attr);
45bool MCond::set(
void* addr)
47 m_cond = (pthread_cond_t*)addr;
53 pthread_cond_destroy(m_cond);
59 if (pthread_cond_signal(m_cond) == 0)
return true;
63bool MCond::broadcast()
65 if (pthread_cond_broadcast(m_cond) == 0)
return true;
69bool MCond::wait(
MMutex& cond)
71 if (pthread_cond_wait(m_cond, cond.m_mu) != 0) {
77bool MCond::wait(
MMutex& mutex,
const unsigned int sec,
78 const unsigned int msec)
81 struct timespec timeout;
83 gettimeofday(&now, NULL);
84 timeout.tv_sec = now.tv_sec + sec;
85 timeout.tv_nsec = now.tv_usec * 1000 + msec;
86 if (pthread_cond_timedwait(m_cond, mutex.m_mu, &timeout) != 0) {
92const MCond& MCond::operator=(
const MCond& cond)
Abstract base class for different kinds of events.