FIX::Mutex Class Reference

Portable implementation of a mutex. More...

`#include <Mutex.h>`

## Public Member Functions

| Mutex ()
| ~Mutex ()
void | lock ()
void | unlock ()

## Private Attributes

pthread_mutex_t | m_mutex
pthread_t | m_threadID
int | m_count

## Detailed Description

Portable implementation of a mutex.

Definition at line 30 of file Mutex.h.

## Constructor & Destructor Documentation

## Mutex()

FIX::Mutex::Mutex | ( |  | ) |

inline

Definition at line 33 of file Mutex.h.

References m_count, m_mutex, and m_threadID.

{
#ifdef _MSC_VER
InitializeCriticalSection( &m_mutex );
#else
m_count = 0;
m_threadID = 0;
//pthread_mutexattr_t attr;
//pthread_mutexattr_init(&attr);
//pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
//pthread_mutex_init(&m_mutex, &attr);
pthread_mutex_init( &m_mutex, 0 );
#endif
}
FIX::Mutex::m_mutex
pthread_mutex_t m_mutex
Definition: Mutex.h:88
FIX::Mutex::m_threadID
pthread_t m_threadID
Definition: Mutex.h:89
FIX::Mutex::m_count
int m_count
Definition: Mutex.h:90

## ~Mutex()

FIX::Mutex::~Mutex | ( |  | ) |

inline

Definition at line 48 of file Mutex.h.

References m_mutex.

{
#ifdef _MSC_VER
DeleteCriticalSection( &m_mutex );
#else
pthread_mutex_destroy( &m_mutex );
#endif
}
FIX::Mutex::m_mutex
pthread_mutex_t m_mutex
Definition: Mutex.h:88

## Member Function Documentation

## lock()

void FIX::Mutex::lock | ( |  | ) |

inline

Definition at line 57 of file Mutex.h.

References m_count, m_mutex, and m_threadID.

{
#ifdef _MSC_VER
EnterCriticalSection( &m_mutex );
#else
if ( m_count && m_threadID == pthread_self() )
{ ++m_count; return ; }
pthread_mutex_lock( &m_mutex );
++m_count;
m_threadID = pthread_self();
#endif
}
FIX::Mutex::m_mutex
pthread_mutex_t m_mutex
Definition: Mutex.h:88
FIX::Mutex::m_threadID
pthread_t m_threadID
Definition: Mutex.h:89
FIX::Mutex::m_count
int m_count
Definition: Mutex.h:90

## unlock()

void FIX::Mutex::unlock | ( |  | ) |

inline

Definition at line 70 of file Mutex.h.

References m_count, m_mutex, and m_threadID.

{
#ifdef _MSC_VER
LeaveCriticalSection( &m_mutex );
#else
if ( m_count > 1 )
{ m_count--; return ; }
--m_count;
m_threadID = 0;
pthread_mutex_unlock( &m_mutex );
#endif
}
FIX::Mutex::m_mutex
pthread_mutex_t m_mutex
Definition: Mutex.h:88
FIX::Mutex::m_threadID
pthread_t m_threadID
Definition: Mutex.h:89
FIX::Mutex::m_count
int m_count
Definition: Mutex.h:90

## Member Data Documentation

## m_count

int FIX::Mutex::m_count

private

Definition at line 90 of file Mutex.h.

Referenced by lock(), Mutex(), and unlock().

## m_mutex

pthread_mutex_t FIX::Mutex::m_mutex

private

Definition at line 88 of file Mutex.h.

Referenced by lock(), FIX::Locker::Locker(), Mutex(), FIX::ReverseLocker::ReverseLocker(), unlock(), FIX::Locker::~Locker(), ~Mutex(), and FIX::ReverseLocker::~ReverseLocker().

## m_threadID

pthread_t FIX::Mutex::m_threadID

private

Definition at line 89 of file Mutex.h.

Referenced by lock(), Mutex(), and unlock().

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

- Mutex.h