Belle II Software development
RWLock Class Reference

Public Member Functions

bool init ()
 
bool rdlock ()
 
bool wrlock ()
 
bool unlock ()
 
bool destroy ()
 

Static Public Member Functions

static size_t size ()
 

Private Attributes

pthread_rwlock_t m_lock
 

Detailed Description

Definition at line 19 of file RWLock.h.

Constructor & Destructor Documentation

◆ RWLock()

RWLock ( )

Definition at line 12 of file RWLock.cc.

12: m_lock() {}

◆ ~RWLock()

~RWLock ( )

Definition at line 14 of file RWLock.cc.

14{}

Member Function Documentation

◆ destroy()

bool destroy ( )

Definition at line 52 of file RWLock.cc.

53{
54 if (pthread_rwlock_destroy(&m_lock) != 0) {
55 return true;
56 } else {
57 return false;
58 }
59}

◆ init()

bool init ( )

Definition at line 16 of file RWLock.cc.

17{
18 pthread_rwlockattr_t attr;
19 pthread_rwlockattr_init(&attr);
20 pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
21 pthread_rwlock_init(&m_lock, &attr);
22 pthread_rwlockattr_destroy(&attr);
23 return true;
24}

◆ rdlock()

bool rdlock ( )

Definition at line 26 of file RWLock.cc.

27{
28 if (pthread_rwlock_rdlock(&m_lock) != 0) {
29 return false;
30 } else {
31 return true;
32 }
33}

◆ size()

static size_t size ( )
inlinestatic

Definition at line 22 of file RWLock.h.

23 {
24 return sizeof(pthread_rwlock_t);
25 }

◆ unlock()

bool unlock ( )

Definition at line 43 of file RWLock.cc.

44{
45 if (pthread_rwlock_unlock(&m_lock) != 0) {
46 return true;
47 } else {
48 return false;
49 }
50}

◆ wrlock()

bool wrlock ( )

Definition at line 35 of file RWLock.cc.

36{
37 if (pthread_rwlock_wrlock(&m_lock) != 0) {
38 return false;
39 }
40 return true;
41}

Member Data Documentation

◆ m_lock

pthread_rwlock_t m_lock
private

Definition at line 42 of file RWLock.h.


The documentation for this class was generated from the following files: