![]() |
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 |
Portable implementation of a mutex.
Definition at line 30 of file Mutex.h.
FIX::Mutex::Mutex | ( | ) | [inline] |
Definition at line 33 of file Mutex.h.
References m_count, m_mutex, and m_threadID.
00034 { 00035 #ifdef _MSC_VER 00036 InitializeCriticalSection( &m_mutex ); 00037 #else 00038 m_count = 0; 00039 m_threadID = 0; 00040 //pthread_mutexattr_t attr; 00041 //pthread_mutexattr_init(&attr); 00042 //pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 00043 //pthread_mutex_init(&m_mutex, &attr); 00044 pthread_mutex_init( &m_mutex, 0 ); 00045 #endif 00046 }
FIX::Mutex::~Mutex | ( | ) | [inline] |
void FIX::Mutex::lock | ( | ) | [inline] |
Definition at line 57 of file Mutex.h.
References m_count, m_mutex, and m_threadID.
Referenced by FIX::Locker::Locker(), and FIX::ReverseLocker::~ReverseLocker().
00058 { 00059 #ifdef _MSC_VER 00060 EnterCriticalSection( &m_mutex ); 00061 #else 00062 if ( m_count && m_threadID == pthread_self() ) 00063 { ++m_count; return ; } 00064 pthread_mutex_lock( &m_mutex ); 00065 ++m_count; 00066 m_threadID = pthread_self(); 00067 #endif 00068 }
void FIX::Mutex::unlock | ( | ) | [inline] |
Definition at line 70 of file Mutex.h.
References m_count, m_mutex, and m_threadID.
Referenced by FIX::ReverseLocker::ReverseLocker(), and FIX::Locker::~Locker().
int FIX::Mutex::m_count [private] |
pthread_mutex_t FIX::Mutex::m_mutex [private] |
pthread_t FIX::Mutex::m_threadID [private] |