The message queue class is used to send and wait for Message objects, see MessageThread. More...

#include "murl_util_message_queue.h"

Public Types

enum  Result { FAILED , RECEIVED , TIMEOUT , QUIT }
 Enumeration of the message queue results. More...
 

Public Member Functions

 MessageQueue ()
 The default constructor. More...
 
virtual ~MessageQueue ()
 The destructor.
 
UInt32 GetMaxMessageQueueLength () const
 Get the maximum number of messages the queue can store. More...
 
void SetMaxMessageQueueLength (UInt32 maxLength)
 Set the maximum number of messages the queue can store. More...
 
void ClearMessageQueue ()
 Clear the message queue.
 
Bool SendMessage (Message::AutoPtr message)
 Add a message to the message queue. More...
 
Bool SendSyncMessage (Message::AutoPtr message)
 Add a message the the message queue and wait until the message is delivered and processed, see Message. More...
 
Result WaitMessage (Message::AutoPtr &message, UInt32 msgIdStart, UInt32 msgIdEnd)
 Wait for a message. More...
 
Result WaitMessage (Message::AutoPtr &message, const System::Time &timeout, UInt32 msgIdStart, UInt32 msgIdEnd)
 Wait for a message with time out. More...
 
Result GetMessage (Message::AutoPtr &message, UInt32 msgIdStart, UInt32 msgIdEnd)
 Get a message from the message queue. More...
 
Result PeekMessage (const Message *&message, UInt32 msgIdStart, UInt32 msgIdEnd)
 Peek a message from the message queue. More...
 

Protected Member Functions

Result GetMessage (Message *&message, UInt32 msgIdStart, UInt32 msgIdEnd, Bool remove)
 Get a message raw pointer from the message queue. More...
 

Protected Attributes

System::Mutex mMutex
 The message class mutex.
 
System::Semaphore mMessageArrived
 The message queue semaphore.
 
UInt32 mMaxMessageQueueLength
 The maximum message queue length.
 
Array< Message::AutoPtrmMessages
 The message queue.
 

Detailed Description

The message queue class is used to send and wait for Message objects, see MessageThread.

Member Enumeration Documentation

◆ Result

Enumeration of the message queue results.

Enumerator
FAILED 

Receiving a message failed.

RECEIVED 

Received a message.

TIMEOUT 

Timeout receiving a message.

QUIT 

Received the quit message.

Constructor & Destructor Documentation

◆ MessageQueue()

Murl::Util::MessageQueue::MessageQueue ( )

The default constructor.

Set the message queue length to 1000.

Member Function Documentation

◆ GetMaxMessageQueueLength()

UInt32 Murl::Util::MessageQueue::GetMaxMessageQueueLength ( ) const

Get the maximum number of messages the queue can store.

The default message queue length is 1000.

Returns
The maximum number of messages the queue can store.

◆ SetMaxMessageQueueLength()

void Murl::Util::MessageQueue::SetMaxMessageQueueLength ( UInt32  maxLength)

Set the maximum number of messages the queue can store.

Parameters
maxLengthThe maximum number of messages the queue can store.

◆ SendMessage()

Bool Murl::Util::MessageQueue::SendMessage ( Message::AutoPtr  message)

Add a message to the message queue.

Parameters
messageThe message to send.
Returns
true if successful, false if the maximum message queue length is reached.

◆ SendSyncMessage()

Bool Murl::Util::MessageQueue::SendSyncMessage ( Message::AutoPtr  message)

Add a message the the message queue and wait until the message is delivered and processed, see Message.

Parameters
messageThe message to send.
Returns
true if successful, false if the maximum message queue length is reached.

◆ WaitMessage() [1/2]

Result Murl::Util::MessageQueue::WaitMessage ( Message::AutoPtr message,
UInt32  msgIdStart,
UInt32  msgIdEnd 
)

Wait for a message.

Parameters
messageThe message return value. The message returned is removed from the message queue.
msgIdStartMessage identifier range start. Use Message::ID_ANY to receive any message (set msgIdEnd to zero).
msgIdEndMessage identifier range end.
Returns
The message queue result.

◆ WaitMessage() [2/2]

Result Murl::Util::MessageQueue::WaitMessage ( Message::AutoPtr message,
const System::Time timeout,
UInt32  msgIdStart,
UInt32  msgIdEnd 
)

Wait for a message with time out.

Parameters
messageThe message return value. The message returned is removed from the message queue.
timeoutThe maximum time to wait.
msgIdStartMessage identifier range start. Use Message::ID_ANY to receive any message (set msgIdEnd to zero).
msgIdEndMessage identifier range end.
Returns
The message queue result.

◆ GetMessage() [1/2]

Result Murl::Util::MessageQueue::GetMessage ( Message::AutoPtr message,
UInt32  msgIdStart,
UInt32  msgIdEnd 
)

Get a message from the message queue.

Parameters
messageThe message return value. The message returned is removed from the message queue.
msgIdStartMessage identifier range start. Use Message::ID_ANY to receive any message (set msgIdEnd to zero).
msgIdEndMessage identifier range end.
Returns
The message queue result.

◆ PeekMessage()

Result Murl::Util::MessageQueue::PeekMessage ( const Message *&  message,
UInt32  msgIdStart,
UInt32  msgIdEnd 
)

Peek a message from the message queue.

Checks if a message is in the message queue but does not remove the message from the message queue.

Parameters
messageThe message return value.
msgIdStartMessage identifier range start. Use Message::ID_ANY to receive any message (set msgIdEnd to zero).
msgIdEndMessage identifier range end.
Returns
The message queue result.

◆ GetMessage() [2/2]

Result Murl::Util::MessageQueue::GetMessage ( Message *&  message,
UInt32  msgIdStart,
UInt32  msgIdEnd,
Bool  remove 
)
protected

Get a message raw pointer from the message queue.

Parameters
messageThe message return value.
msgIdStartMessage identifier range start. Use Message::ID_ANY to receive any message (set msgIdEnd to zero).
msgIdEndMessage identifier range end.
removeIf true remove the message from the queue.
Returns
The message queue result.

The documentation for this class was generated from the following file:
  • murl_util_message_queue.h


Copyright © 2011-2024 Spraylight GmbH.