![]() |
Murl Engine API
Version 2018.3
|
The MessageThread class implements a thread with a ready to use MessageQueue and MessageDispatch class. More...
#include <murl_util_message_thread.h>
The MessageThread class implements a thread with a ready to use MessageQueue and MessageDispatch class.
Example for sending data to different methods:
Public Member Functions | |
MessageThread () | |
The default constructor. | |
MessageThread (const String &name) | |
Constructor taking a thread name. More... | |
virtual | ~MessageThread () |
The destructor. More... | |
virtual Bool | Start () |
Create and start the thread. More... | |
virtual Bool | Start (const System::Time &timeout) |
Create and start the thread, run the message loop with timeout. More... | |
virtual void | Stop () |
Stop the thread. More... | |
void | SetTimeout (const System::Time &timeout) |
Set the message loop timeout. More... | |
const System::Time & | GetTimeout () const |
Get the message loop timeout. More... | |
MessageQueue & | GetMessageQueue () |
Get the thread's message queue object. More... | |
MessageDispatch & | GetMessageDispatch () |
Get the thread's message dispatch object. More... | |
virtual Bool | SendQuit () |
Send the ID_QUIT message to the thread. More... | |
virtual Bool | SendId (UInt32 messageId) |
Send the Message object to the thread. More... | |
virtual Bool | SendMessage (Message::AutoPtr message) |
Send a message object to the thread. More... | |
virtual Bool | SendSyncMessage (Message::AutoPtr message) |
Send a message object to the thread and wait until the message is delivered and processed. More... | |
![]() | |
virtual | ~Thread () |
The destructor. | |
virtual void | Join () |
Join and destroy the thread. More... | |
virtual void | Flush () |
Flush the autorelease memory pool. More... | |
Protected Member Functions | |
virtual MessageQueue::Result | WaitMessage (Message::AutoPtr &message) |
Wait for a message (using Message::ID_ANY). More... | |
virtual MessageQueue::Result | WaitMessage (Message::AutoPtr &message, const System::Time &timeout) |
Wait for a message with timeout (using Message::ID_ANY). More... | |
virtual MessageQueue::Result | GetMessage (Message::AutoPtr &message) |
Get a message from the message queue (using Message::ID_ANY). More... | |
virtual MessageQueue::Result | PeekMessage (const Message *&message) |
Peek a message from the message queue (using Message::ID_ANY). More... | |
virtual Bool | Run () |
The System::Thread::Run() method implementation. More... | |
virtual MessageQueue::Result | DispatchMessage (Message::AutoPtr &message) |
Wait for a message and dispatch the message. More... | |
virtual MessageQueue::Result | DispatchMessage (Message::AutoPtr &message, const System::Time &timeout) |
Wait for a message and dispatch the message with timeout. More... | |
![]() | |
Thread (const String &name) | |
Constructor taking a thread name. More... | |
Protected Attributes | |
MessageQueue | mMessageQueue |
The message queue instance. More... | |
MessageDispatch | mMessageDispatch |
The message dispatch instance. More... | |
System::Time | mTimeout |
The message loop timeout. More... | |
![]() | |
Bool | mIsRunning |
The running state of the thread. More... | |
String | mName |
The name of the thread. More... | |
UInt64 | mThreadId |
The identifier of the thread. More... | |
ThreadHandle * | mHandle |
The anonymous thread handle for internal use only. More... | |
Additional Inherited Members | |
![]() | |
enum | SchedulingPriority { SCHEDULING_PRIORITY_LOWEST, SCHEDULING_PRIORITY_NORMAL, SCHEDULING_PRIORITY_HIGHEST } |
Thread scheduling priority enumeration. More... | |
enum | SchedulingPolicy { SCHEDULING_POLICY_OTHER, SCHEDULING_POLICY_FIFO, SCHEDULING_POLICY_ROUND_ROBIN } |
Thread scheduling policy enumeration. More... | |
![]() | |
static Bool | SetCurrentPriority (SchedulingPriority priority, SchedulingPolicy policy=SCHEDULING_POLICY_OTHER) |
Set the current thread's priority and scheduling policy. More... | |
static Bool | SetCurrentAffinityMask (UInt32 mask) |
Set the current thread's CPU affinity mask. More... | |
static UInt64 | GetCurrentId () |
Get the current thread identifier. More... | |
Murl::Util::MessageThread::MessageThread | ( | const String & | name | ) |
Constructor taking a thread name.
name | The thread name. |
|
virtual |
The destructor.
Calls Stop() and System::Thread::Join().
|
virtual |
Create and start the thread.
Reimplemented from Murl::System::Thread.
|
virtual |
Create and start the thread, run the message loop with timeout.
If a timeout occurs the message dispatcher timeout method is called which executes the MessageDispatch::RegisterTimeout() callback object.
timeout | The maximum time to wait for messages. |
|
virtual |
Stop the thread.
Calls SendQuit() and System::Thread::Stop().
Reimplemented from Murl::System::Thread.
void Murl::Util::MessageThread::SetTimeout | ( | const System::Time & | timeout | ) |
Set the message loop timeout.
timeout | The maximum time to wait for messages. |
const System::Time& Murl::Util::MessageThread::GetTimeout | ( | ) | const |
Get the message loop timeout.
MessageQueue& Murl::Util::MessageThread::GetMessageQueue | ( | ) |
Get the thread's message queue object.
MessageDispatch& Murl::Util::MessageThread::GetMessageDispatch | ( | ) |
Get the thread's message dispatch object.
|
virtual |
Send the ID_QUIT message to the thread.
Send the Message object to the thread.
messageId | The message identifier to send. |
|
virtual |
Send a message object to the thread.
message | The message object to send. |
|
virtual |
Send a message object to the thread and wait until the message is delivered and processed.
If this method is called from it's own thread context the message is dispatched immediately.
message | The message object to send. |
|
protectedvirtual |
Wait for a message (using Message::ID_ANY).
message | The message return value. The message returned is removed from the message queue. |
|
protectedvirtual |
Wait for a message with timeout (using Message::ID_ANY).
message | The message return value. The message returned is removed from the message queue. |
timeout | The maximum time to wait. |
|
protectedvirtual |
Get a message from the message queue (using Message::ID_ANY).
message | The message return value. The message returned is removed from the message queue. |
|
protectedvirtual |
Peek a message from the message queue (using Message::ID_ANY).
Checks if a message is in the message queue but does not remove the message from the message queue.
message | The message return value. |
|
protectedvirtual |
The System::Thread::Run() method implementation.
Implements the message loop:
Implements Murl::System::Thread.
|
protectedvirtual |
Wait for a message and dispatch the message.
message | The message return value. |
|
protectedvirtual |
Wait for a message and dispatch the message with timeout.
message | The message return value. |
timeout | The maximum time to wait. |
|
protected |
The message queue instance.
|
protected |
The message dispatch instance.
|
protected |
The message loop timeout.