Belle II Software  release-05-01-25
RWLock.cc
1 #include "daq/slc/system/RWLock.h"
2 
3 using namespace Belle2;
4 
5 RWLock::RWLock() : m_lock() {}
6 
7 RWLock::~RWLock() {}
8 
9 bool RWLock::init()
10 {
11  pthread_rwlockattr_t attr;
12  pthread_rwlockattr_init(&attr);
13  pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
14  pthread_rwlock_init(&m_lock, &attr);
15  pthread_rwlockattr_destroy(&attr);
16  return true;
17 }
18 
19 bool RWLock::rdlock()
20 {
21  if (pthread_rwlock_rdlock(&m_lock) != 0) {
22  return false;
23  } else {
24  return true;
25  }
26 }
27 
28 bool RWLock::wrlock()
29 {
30  if (pthread_rwlock_wrlock(&m_lock) != 0) {
31  return false;
32  }
33  return true;
34 }
35 
36 bool RWLock::unlock()
37 {
38  if (pthread_rwlock_unlock(&m_lock) != 0) {
39  return true;
40  } else {
41  return false;
42  }
43 }
44 
45 bool RWLock::destroy()
46 {
47  if (pthread_rwlock_destroy(&m_lock) != 0) {
48  return true;
49  } else {
50  return false;
51  }
52 }
53 
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19