Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
Public Types | Public Member Functions | Private Attributes | List of all members
JSYNCHRONIZATION::JMutex Class Reference

Mutex. More...

#include <JMutex.hh>

Public Types

typedef JBasicScopedLock< JMutexJScopedLock
 

Public Member Functions

 JMutex ()
 Constructor. More...
 
 ~JMutex ()
 Destructor. More...
 
int lock ()
 Lock the mutex. More...
 
int try_lock ()
 Try lock the mutex. More...
 
int unlock ()
 Unlock the mutex. More...
 

Private Attributes

pthread_mutex_t m_mutex
 

Detailed Description

Mutex.

Definition at line 95 of file JMutex.hh.

Member Typedef Documentation

◆ JScopedLock

Definition at line 147 of file JMutex.hh.

Constructor & Destructor Documentation

◆ JMutex()

JSYNCHRONIZATION::JMutex::JMutex ( )
inline

Constructor.

Definition at line 104 of file JMutex.hh.

105  {
106  pthread_mutex_init(&m_mutex, 0);
107  }
pthread_mutex_t m_mutex
Definition: JMutex.hh:97

◆ ~JMutex()

JSYNCHRONIZATION::JMutex::~JMutex ( )
inline

Destructor.

Definition at line 112 of file JMutex.hh.

113  {
114  pthread_mutex_destroy(&m_mutex);
115  }

Member Function Documentation

◆ lock()

int JSYNCHRONIZATION::JMutex::lock ( )
inline

Lock the mutex.

Returns
0 on success, an error code otherwise. See man 3p pthread_mutex_lock for further info.

Definition at line 122 of file JMutex.hh.

123  {
124  return pthread_mutex_lock(&m_mutex);
125  }

◆ try_lock()

int JSYNCHRONIZATION::JMutex::try_lock ( )
inline

Try lock the mutex.

Returns
0 on success, an error code otherwise. See man 3p pthread_mutex_lock for further info.

Definition at line 132 of file JMutex.hh.

133  {
134  return pthread_mutex_trylock(&m_mutex);
135  }

◆ unlock()

int JSYNCHRONIZATION::JMutex::unlock ( )
inline

Unlock the mutex.

Returns
0 on success, an error code otherwise. See man 3p pthread_mutex_lock for further info.

Definition at line 142 of file JMutex.hh.

143  {
144  return pthread_mutex_unlock(&m_mutex);
145  }

Member Data Documentation

◆ m_mutex

pthread_mutex_t JSYNCHRONIZATION::JMutex::m_mutex
private

Definition at line 97 of file JMutex.hh.


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