Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy 

FIX::Mutex Class Reference

Portable implementation of a mutex. More...

#include <Mutex.h>

List of all members.

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

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]

Definition at line 48 of file Mutex.h.

References m_mutex.

00049   {
00050 #ifdef _MSC_VER
00051     DeleteCriticalSection( &m_mutex );
00052 #else
00053     pthread_mutex_destroy( &m_mutex );
00054 #endif
00055   }


Member Function Documentation

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().

00071   {
00072 #ifdef _MSC_VER
00073     LeaveCriticalSection( &m_mutex );
00074 #else
00075     if ( m_count > 1 )
00076     { m_count--; return ; }
00077     --m_count;
00078     m_threadID = 0;
00079     pthread_mutex_unlock( &m_mutex );
00080 #endif
00081   }


Member Data Documentation

int FIX::Mutex::m_count [private]

Definition at line 90 of file Mutex.h.

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

pthread_mutex_t FIX::Mutex::m_mutex [private]

Definition at line 88 of file Mutex.h.

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

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:

Generated on Mon Apr 5 21:00:09 2010 for QuickFIX by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2001