EpcTools
An event based multi-threaded C++ development framework.
|
base class for EThreadPrivate and EThreadPublic More...
#include <etevent.h>
Public Member Functions | |
EThreadEvent () | |
Default class constructor. More... | |
~EThreadEvent () | |
Rhe class destructor. More... | |
Bool | sendMessage (UInt message, Bool wait=True) |
Sends event message to this thread. More... | |
Bool | sendMessage (UInt message, pVoid voidptr, Bool wait=True) |
Sends event message to this thread. More... | |
Bool | sendMessage (const TMessage &msg, Bool wait=True) |
Sends event message to this thread. More... | |
virtual Void | init (Short appId, UShort threadId, pVoid arg, Int queueSize=16384, Bool suspended=False, Dword stackSize=0) |
Initializes the thread object. More... | |
Void | quit () |
Posts the quit message to this thread. More... | |
Void | start () |
Initializes the thread when it was suspended at init(). More... | |
Void | suspend () |
Suspends a running thread. More... | |
Void | resume () |
Resumes a suspended thread. More... | |
virtual Void | onInit () |
Called in the context of the thread when the EM_INIT event is processed. More... | |
virtual Void | onQuit () |
Called in the context of the thread when the EM_QUIT event is processed. More... | |
virtual Void | onSuspend () |
Called in the context of the thread when th EM_SUSPEND event is processed. More... | |
virtual Void | onTimer (EThreadEventTimer *ptimer) |
Called in the context of the thread when th EM_TIMER event is processed. More... | |
Void | initTimer (EThreadEventTimer &t) |
Intializes an EThreadEvent::Timer object and associates with this thread. More... | |
ESemaphoreData & | getMsgSemaphore () |
Returns the semaphore associated with this thread's event queue. More... | |
![]() | |
EThreadBasic () | |
Class constructor. More... | |
virtual | ~EThreadBasic () |
Class destructor. More... | |
Void | init (pVoid arg, size_t stackSize=0) |
Initialize and start the thread. More... | |
Void | join () |
Waits for the thread to terminate. More... | |
Bool | isInitialized () |
Returns the thread initialization state. More... | |
RunState | getRunState () |
Returns the current thread run state. More... | |
Bool | isWaitingToRun () |
Determines if the thread is waiting to run. More... | |
Bool | isRunning () |
Determines if the thread is running. More... | |
Bool | isDoneRunning () |
Determines if the thread has finished running. More... | |
Int | cancelWait () |
Sends a cancellation request to the thread. More... | |
Void | signal (Int sig) |
Protected Member Functions | |
virtual Void | messageQueued () |
Called when an event message is queued. More... | |
Bool | pumpMessage (TMessage &msg, Bool wait=true) |
Dispatches the next thread event message. More... | |
virtual Void | pumpMessages () |
Process event messages. More... | |
virtual Void | defaultMessageHandler (TMessage &msg) |
The default event message handler. More... | |
pid_t | getThreadId () |
Retrieves the internal thread ID. More... | |
Additional Inherited Members | |
![]() | |
enum | RunState { rsWaitingToRun, rsRunning, rsDoneRunning } |
EThreadBasic run states. More... | |
![]() | |
static Void | sleep (Int milliseconds) |
Sleeps for the specified number of milliseconds. More... | |
static Void | yield () |
Relinquishes the CPU. More... | |
![]() | |
static Void | Initialize () |
performs internal initialization *** DO NOT CALL *** More... | |
static Void | UnInitialize () |
performs internal de-initialization *** DO NOT CALL *** More... | |
base class for EThreadPrivate and EThreadPublic
The EThreadBase class provides event dispatching and timer management functionality that are part of EThreadPrivate and EThreadPublic. the EThreadPrivate and EThreadPublic classes. This functionality includes event dispatching
|
inline |
Default class constructor.
|
inline |
Rhe class destructor.
|
inlineprotectedvirtual |
The default event message handler.
msg | the EThreadMessage event object |
This method is called when no event handler has been defined in the class heirarchy for a specified thread event.
|
inline |
Returns the semaphore associated with this thread's event queue.
|
inlineprotected |
Retrieves the internal thread ID.
|
inlinevirtual |
Initializes the thread object.
appId | identifies the application this thread is associated with. |
threadId | identifies the thread within this application. |
arg | an argument that will be passed through to the internal thread procedure. Currently not used. |
queueSize | the maximum number of unprocessed entries in the event queue. |
suspended | if True, the thread is started in a suspended state. |
stackSize | the stack size. |
|
inline |
Intializes an EThreadEvent::Timer object and associates with this thread.
t | the EThreadEvent::Timer object to initialize |
|
inlineprotectedvirtual |
Called when an event message is queued.
This method is called in the context of the thread where sendMessage() is called after the message has been added to the thread's event queue.
|
inlinevirtual |
Called in the context of the thread when the EM_INIT event is processed.
|
inlinevirtual |
Called in the context of the thread when the EM_QUIT event is processed.
|
inlinevirtual |
Called in the context of the thread when th EM_SUSPEND event is processed.
|
inlinevirtual |
Called in the context of the thread when th EM_TIMER event is processed.
ptimer | a pointer to the EThreadBase::Timer object that expired |
|
inlineprotected |
Dispatches the next thread event message.
msg | the EThreadMessage event object |
wait | waits for the next EThreadMessage to be processed |
This method retrieves the next event message from the threads event queue and processes the event by calling the first event handler as defined by the class heirarchy. If no event message is available and the wait parameter is true, then the thread will block waiting on the next event message to be sent to the thread. If there is no event handler defined in the class heirarchy for a particular event ID, the default event handler, defMessageHandler(), will be called.
|
inlineprotectedvirtual |
Process event messages.
EError | catches and re-throws any exception raised by pumpMessage |
Any overridden version of pumpMessages() must call pumpMessage() to process each individual message.
|
inline |
Posts the quit message to this thread.
|
inline |
Resumes a suspended thread.
|
inline |
Sends event message to this thread.
msg | the message thread message object to send. |
wait | waits for the message to be sent |
Sends (posts) the supplied event message to this thread's event queue.
|
inline |
Sends event message to this thread.
message | the message ID |
wait | waits for the message to be sent |
Sends (posts) an event message to this threads event queue. No additional data is posted with the event.
|
inline |
Sends event message to this thread.
message | the message ID. |
voidptr | a void pointer to be included with the message. |
wait | waits for the message to be sent. |
Sends (posts) an event message to this threads event queue. No additional data is posted with the event.
|
inline |
Initializes the thread when it was suspended at init().
|
inline |
Suspends a running thread.
Suspends a running thread by posting the EM_SUSPEND message to the threads event queue. The thread will call the onSuspend() method when the EM_SUSPEND event is processed. The thread will not process any more thread messages until the resume() method is called.