Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JSYNCHRONIZATION::JMutex Class Reference

Mutex. More...

#include <JMutex.hh>

Public Types

typedef JBasicScopedLock< JMutexJScopedLock
 

Public Member Functions

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

Private Attributes

pthread_mutex_t m_mutex
 

Detailed Description

Mutex.

Definition at line 95 of file JMutex.hh.

Member Typedef Documentation

◆ JScopedLock

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: