Nebula
Loading...
Searching...
No Matches
Messaging::BlockingHandlerThread Class Reference

#include <blockinghandlerthread.h>

Detailed Description

Message handler thread class which blocks until messages arrive (or optionally, a time-out occurs).

Inherits Messaging::HandlerThreadBase.

Public Member Functions

 BlockingHandlerThread ()
 constructor
 
void SetWaitTimeout (int milliSec)
 set optional wait timeout (0 if infinite)
 
int GetWaitTimeout () const
 get wait timeout
 
virtual void AddMessage (const Ptr< Message > &msg)
 add a message to be handled (override in subclass!)
 
virtual void CancelMessage (const Ptr< Message > &msg)
 cancel a pending message (override in subclass!)
 
virtual void EmitWakeupSignal ()
 called if thread needs a wakeup call before stopping
 
virtual void DoWork ()
 this method runs in the thread context
 
- Public Member Functions inherited from Messaging::HandlerThreadBase
 HandlerThreadBase ()
 constructor
 
void AttachHandler (const Ptr< Handler > &h)
 attach a message handler
 
void RemoveHandler (const Ptr< Handler > &h)
 dynamically remove a message handler
 
void ClearHandlers ()
 clear all attached message handlers
 
void WaitForHandlersOpened ()
 wait until handlers have been opened
 
virtual void WaitForMessage (const Ptr< Message > &msg)
 wait for message to be handled (optionally override in subclass!)
 

Private Member Functions

 __DeclareClass (BlockingHandlerThread)
 

Private Attributes

int waitTimeout
 
Threading::SafeQueue< Ptr< Message > > msgQueue
 

Additional Inherited Members

- Protected Member Functions inherited from Messaging::HandlerThreadBase
void ThreadOpenHandlers ()
 open message handlers
 
void ThreadCloseHandlers ()
 close message handlers
 
void ThreadUpdateHandlers ()
 open dynamically added handlers, and call DoWork() on all attached handlers
 
bool ThreadUpdateDeferredMessages ()
 update deferred messages, return true if at least one message has been handled
 
void ThreadDiscardDeferredMessages ()
 clear leftover deferred messages
 
bool ThreadHandleMessages (const Util::Array< Ptr< Message > > &msgArray)
 handle messages in array, return true if at least one message has been handled
 
bool ThreadHandleSingleMessage (const Ptr< Message > &msg)
 handle a single message without deferred support, return if message has been handled
 
void ThreadSignalMessageHandled ()
 signal message handled event (only call if at least one message has been handled)
 
- Protected Attributes inherited from Messaging::HandlerThreadBase
Threading::Event msgHandledEvent
 
Threading::Event handlersOpenedEvent
 
Threading::CriticalSection handlersCritSect
 
Util::Array< Ptr< Handler > > handlers
 
Util::Array< Ptr< Message > > deferredMessages
 

Constructor & Destructor Documentation

◆ BlockingHandlerThread()

Messaging::BlockingHandlerThread::BlockingHandlerThread ( )

constructor

Member Function Documentation

◆ __DeclareClass()

Messaging::BlockingHandlerThread::__DeclareClass ( BlockingHandlerThread )
private

◆ AddMessage()

void Messaging::BlockingHandlerThread::AddMessage ( const Ptr< Message > & msg)
virtual

add a message to be handled (override in subclass!)

This adds a new message to the thread's message queue.

Reimplemented from Messaging::HandlerThreadBase.

◆ CancelMessage()

void Messaging::BlockingHandlerThread::CancelMessage ( const Ptr< Message > & msg)
virtual

cancel a pending message (override in subclass!)

This removes a message from the thread's message queue, regardless of its state.

Reimplemented from Messaging::HandlerThreadBase.

◆ DoWork()

void Messaging::BlockingHandlerThread::DoWork ( )
virtual

this method runs in the thread context

The message processing loop.

◆ EmitWakeupSignal()

void Messaging::BlockingHandlerThread::EmitWakeupSignal ( )
virtual

called if thread needs a wakeup call before stopping

This method is called by Thread::Stop() after setting the stopRequest event and before waiting for the thread to stop.

◆ GetWaitTimeout()

int Messaging::BlockingHandlerThread::GetWaitTimeout ( ) const
inline

get wait timeout

◆ SetWaitTimeout()

void Messaging::BlockingHandlerThread::SetWaitTimeout ( int milliSec)
inline

set optional wait timeout (0 if infinite)

Member Data Documentation

◆ msgQueue

Threading::SafeQueue<Ptr<Message> > Messaging::BlockingHandlerThread::msgQueue
private

◆ waitTimeout

int Messaging::BlockingHandlerThread::waitTimeout
private

The documentation for this class was generated from the following files: