8 #include "daq/slc/system/MMutex.h"
14 MMutex::MMutex(
const MMutex& mutex)
19 MMutex::MMutex(
void* addr)
21 set((pthread_mutex_t*)addr);
26 bool MMutex::init(
void* addr)
35 pthread_mutexattr_t attr;
36 pthread_mutexattr_init(&attr);
37 pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
38 pthread_mutex_init(m_mu, &attr);
39 pthread_mutexattr_destroy(&attr);
43 bool MMutex::set(
void* addr)
45 m_mu = (pthread_mutex_t*)addr;
51 if (pthread_mutex_lock(m_mu) != 0) {
58 bool MMutex::trylock()
60 if (pthread_mutex_lock(m_mu) != 0) {
68 if (pthread_mutex_unlock(m_mu) != 0) {
75 bool MMutex::destroy()
77 if (pthread_mutex_destroy(m_mu) != 0) {
Abstract base class for different kinds of events.