Public Member Functions | Private Attributes
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.

  {
#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::~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
  }

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

  {
#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
  }
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().

  {
#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
  }

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 Jun 23 2014 23:49:39 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001