Public Member Functions | Private Attributes
FIX::Event Class Reference

Portable implementation of an event/conditional mutex. More...

#include <Event.h>

List of all members.

Public Member Functions

 Event ()
 ~Event ()
void signal ()
void wait (double s)

Private Attributes

pthread_cond_t m_event
pthread_mutex_t m_mutex

Detailed Description

Portable implementation of an event/conditional mutex.

Definition at line 36 of file Event.h.


Constructor & Destructor Documentation

FIX::Event::Event ( ) [inline]

Definition at line 39 of file Event.h.

References m_event, and m_mutex.

  {
#ifdef _MSC_VER
    m_event = CreateEvent( 0, false, false, 0 );
#else
    pthread_mutex_init( &m_mutex, 0 );
    pthread_cond_init( &m_event, 0 );
#endif
  }
FIX::Event::~Event ( ) [inline]

Definition at line 49 of file Event.h.

References m_event, and m_mutex.

  {
#ifdef _MSC_VER
    CloseHandle( m_event );
#else
    pthread_cond_destroy( &m_event );
    pthread_mutex_destroy( &m_mutex );
#endif
  }

Member Function Documentation

void FIX::Event::signal ( ) [inline]

Definition at line 59 of file Event.h.

References m_event, and m_mutex.

Referenced by FIX::Queue< T >::signal().

  {
#ifdef _MSC_VER
    SetEvent( m_event );
#else
    pthread_mutex_lock( &m_mutex );
    pthread_cond_broadcast( &m_event );
    pthread_mutex_unlock( &m_mutex );
#endif
  }
void FIX::Event::wait ( double  s) [inline]

Definition at line 70 of file Event.h.

References m_event, and m_mutex.

Referenced by FIX::Queue< T >::wait().

  {
#ifdef _MSC_VER
    WaitForSingleObject( m_event, (long)(s * 1000) );
#else
    pthread_mutex_lock( &m_mutex );
    timespec time, remainder;
    double intpart;
    time.tv_nsec = (long)(modf(s, &intpart) * 1e9);
    time.tv_sec = (int)intpart;
    pthread_cond_timedwait( &m_event, &m_mutex, &time );
    pthread_mutex_unlock( &m_mutex );
#endif
  }

Member Data Documentation

pthread_cond_t FIX::Event::m_event [private]

Definition at line 89 of file Event.h.

Referenced by Event(), signal(), wait(), and ~Event().

pthread_mutex_t FIX::Event::m_mutex [private]

Definition at line 90 of file Event.h.

Referenced by Event(), signal(), wait(), and ~Event().


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