Public Member Functions | Private Attributes | List of all members
FIX::Event Class Reference

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

#include <Event.h>

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

◆ Event()

FIX::Event::Event ( )
inline

Definition at line 39 of file Event.h.

40 {
41#ifdef _MSC_VER
42 m_event = CreateEvent( 0, false, false, 0 );
43#else
44 pthread_mutex_init( &m_mutex, 0 );
45 pthread_cond_init( &m_event, 0 );
46#endif
47 }
pthread_cond_t m_event
Definition Event.h:89
pthread_mutex_t m_mutex
Definition Event.h:90

References m_event, and m_mutex.

◆ ~Event()

FIX::Event::~Event ( )
inline

Definition at line 49 of file Event.h.

50 {
51#ifdef _MSC_VER
52 CloseHandle( m_event );
53#else
54 pthread_cond_destroy( &m_event );
55 pthread_mutex_destroy( &m_mutex );
56#endif
57 }

References m_event, and m_mutex.

Member Function Documentation

◆ signal()

void FIX::Event::signal ( )
inline

Definition at line 59 of file Event.h.

60 {
61#ifdef _MSC_VER
62 SetEvent( m_event );
63#else
64 pthread_mutex_lock( &m_mutex );
65 pthread_cond_broadcast( &m_event );
66 pthread_mutex_unlock( &m_mutex );
67#endif
68 }

References m_event, and m_mutex.

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

◆ wait()

void FIX::Event::wait ( double  s)
inline

Definition at line 70 of file Event.h.

71 {
72#ifdef _MSC_VER
73 WaitForSingleObject( m_event, (long)(s * 1000) );
74#else
75 pthread_mutex_lock( &m_mutex );
76 timespec time, remainder;
77 double intpart;
78 time.tv_nsec = (long)(modf(s, &intpart) * 1e9);
79 time.tv_sec = (int)intpart;
80 pthread_cond_timedwait( &m_event, &m_mutex, &time );
81 pthread_mutex_unlock( &m_mutex );
82#endif
83 }

References m_event, and m_mutex.

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

Member Data Documentation

◆ m_event

pthread_cond_t FIX::Event::m_event
private

Definition at line 89 of file Event.h.

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

◆ m_mutex

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 Oct 14 2024 06:04:44 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001