Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Private Attributes | List of all members
CAReadWriteLock Class Reference

#include <CAReadWriteLock.hpp>

Collaboration diagram for CAReadWriteLock:

Public Member Functions

 CAReadWriteLock ()
 
 ~CAReadWriteLock ()
 
SINT32 lockRead ()
 
SINT32 lockWrite ()
 
SINT32 unlock ()
 

Private Attributes

CAMutexm_pMutex
 

Detailed Description

Definition at line 34 of file CAReadWriteLock.hpp.

Constructor & Destructor Documentation

◆ CAReadWriteLock()

CAReadWriteLock::CAReadWriteLock ( )

Definition at line 33 of file CAReadWriteLock.cpp.

34 {
35  #ifdef HAVE_PTHREAD_MUTEXES
36  m_pMutex=new pthread_rwlock_t;
37  pthread_rwlock_init(m_pMutex, NULL);
38  #else
39  m_pMutex=new CAMutex();
40  #endif
41 }

References m_pMutex.

◆ ~CAReadWriteLock()

CAReadWriteLock::~CAReadWriteLock ( )

Definition at line 43 of file CAReadWriteLock.cpp.

44 {
45  #ifdef HAVE_PTHREAD_MUTEXES
46  pthread_rwlock_destroy(m_pMutex);
47  #endif
48  delete m_pMutex;
49  m_pMutex = NULL;
50 
51 }

References m_pMutex.

Member Function Documentation

◆ lockRead()

SINT32 CAReadWriteLock::lockRead ( )
inline

Definition at line 40 of file CAReadWriteLock.hpp.

41  {
42  #ifdef HAVE_PTHREAD_MUTEXES
43  if(pthread_rwlock_rdlock(m_pMutex)==0)
44  return E_SUCCESS;
45  return E_UNKNOWN;
46  #else
47  return m_pMutex->down();
48  #endif
49  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References E_SUCCESS, E_UNKNOWN, and m_pMutex.

◆ lockWrite()

SINT32 CAReadWriteLock::lockWrite ( )
inline

Definition at line 51 of file CAReadWriteLock.hpp.

52  {
53  #ifdef HAVE_PTHREAD_MUTEXES
54  if(pthread_rwlock_wrlock(m_pMutex)==0)
55  return E_SUCCESS;
56  return E_UNKNOWN;
57  #else
58  return m_pMutex->down();
59  #endif
60  }

References E_SUCCESS, E_UNKNOWN, and m_pMutex.

◆ unlock()

SINT32 CAReadWriteLock::unlock ( )
inline

Definition at line 62 of file CAReadWriteLock.hpp.

63  {
64 #ifdef HAVE_PTHREAD_MUTEXES
65  if (pthread_rwlock_unlock(m_pMutex) == 0)
66  return E_SUCCESS;
67  return E_UNKNOWN;
68 #else
69  return m_pMutex->up();
70 #endif
71  }

References E_SUCCESS, E_UNKNOWN, and m_pMutex.

Member Data Documentation

◆ m_pMutex

CAMutex* CAReadWriteLock::m_pMutex
private

Definition at line 79 of file CAReadWriteLock.hpp.

Referenced by CAReadWriteLock(), lockRead(), lockWrite(), unlock(), and ~CAReadWriteLock().


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