OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TMsgThread Class Reference

TMsgThread implements basic behavior for threads that own message queues, including mutex locking for the queue. More...

#include <owl/msgthred.h>

Inheritance diagram for owl::TMsgThread:
owl::TApplication

Public Types

enum  TCurrent { Current }
 

Public Member Functions

 TMsgThread (TCurrent)
 Attaches to the current running thread.
 
virtual int MessageLoop ()
 Retrieves and processes messages from the thread's message queue using PumpWaitingMessages() until BreakMessageLoop becomes true.
 
virtual bool IdleAction (long idleCount)
 Called each time there are no messages in the queue.
 
virtual bool ProcessMsg (MSG &msg)
 Called for each message that is pulled from the queue, to perform all translation and dispatching.
 
bool PumpWaitingMessages ()
 The inner message loop.
 
void FlushQueue ()
 Flushes all real messages from the message queue.
 
bool IsRunning () const
 Is this queue thread running its message loop?
 

Protected Member Functions

virtual int Run ()
 Runs this message thread, returns when the message queue quits.
 
virtual void InitInstance ()
 Handles initialization for each executing instance of the message thread.
 
virtual int TermInstance (int status)
 Handles termination for each executing instance of the message thread.
 

Protected Attributes

bool BreakMessageLoop
 Message loop is broken via WM_QUIT.
 
int MessageLoopResult
 Return value from message loop.
 
bool LoopRunning
 Track if the loop is running.
 

Detailed Description

TMsgThread implements basic behavior for threads that own message queues, including mutex locking for the queue.

This class provides message queue oriented thread class support. TMsgThread degenerates to a simple message queue owner under non-threaded environments.

Definition at line 44 of file msgthred.h.

Member Enumeration Documentation

◆ TCurrent

Enumerator
Current 

Definition at line 47 of file msgthred.h.

Constructor & Destructor Documentation

◆ TMsgThread()

owl::TMsgThread::TMsgThread ( TCurrent )

Attaches to the current running thread.

This is often the initial process thread, or even the only thread for non-threaded systems.

Definition at line 28 of file msgthred.cpp.

Member Function Documentation

◆ FlushQueue()

void owl::TMsgThread::FlushQueue ( )

Flushes all real messages from the message queue.

Definition at line 147 of file msgthred.cpp.

◆ IdleAction()

bool owl::TMsgThread::IdleAction ( long idleCount)
virtual

Called each time there are no messages in the queue.

Idle count is incremented each time, and zeroed when messages are pumped. Returns whether or not more processing needs to be done.

Reimplemented in owl::TApplication.

Definition at line 91 of file msgthred.cpp.

References TRACEX.

◆ InitInstance()

void owl::TMsgThread::InitInstance ( )
protectedvirtual

Handles initialization for each executing instance of the message thread.

Derived classes can override this to perform initialization for each instance.

Reimplemented in owl::TApplication.

Definition at line 189 of file msgthred.cpp.

References TRACEX.

◆ IsRunning()

bool owl::TMsgThread::IsRunning ( ) const
inline

Is this queue thread running its message loop?

Returns true if this queue thread is running its message loop.

Definition at line 139 of file msgthred.h.

◆ MessageLoop()

int owl::TMsgThread::MessageLoop ( )
virtual

Retrieves and processes messages from the thread's message queue using PumpWaitingMessages() until BreakMessageLoop becomes true.

Catches exceptions to post a quit message and cleanup before resuming.

Calls IdleAction() when there are no messages

Reimplemented in owl::TApplication.

Definition at line 61 of file msgthred.cpp.

References BreakMessageLoop, IdleAction(), MessageLoopResult, and PumpWaitingMessages().

◆ ProcessMsg()

bool owl::TMsgThread::ProcessMsg ( MSG & msg)
virtual

Called for each message that is pulled from the queue, to perform all translation and dispatching.

Returns true to drop out of the pump.

Reimplemented in owl::TApplication.

Definition at line 106 of file msgthred.cpp.

◆ PumpWaitingMessages()

bool owl::TMsgThread::PumpWaitingMessages ( )

The inner message loop.

Retrieves and processes messages from the OWL application's message queue until it is empty. Sets BreakMessageLoop if a WM_QUIT passes through. Calls ProcessAppMsg for each message to allow special pre-handling.

Definition at line 123 of file msgthred.cpp.

References BreakMessageLoop, MessageLoopResult, and ProcessMsg().

◆ Run()

int owl::TMsgThread::Run ( )
protectedvirtual

Runs this message thread, returns when the message queue quits.

Initializes instances. Runs the thread's message loop. Each of the virtual functions called are expected to throw an exception if there is an error. Exceptions that are not handled, that is, where the status remains non-zero, are propagated out of this function. The message queue is still flushed and TermInstance called.

Reimplemented in owl::TApplication.

Definition at line 164 of file msgthred.cpp.

References FlushQueue(), InitInstance(), LoopRunning, MessageLoop(), and TermInstance().

◆ TermInstance()

int owl::TMsgThread::TermInstance ( int status)
protectedvirtual

Handles termination for each executing instance of the message thread.

Called at the end of a Run() with the final return status.

Reimplemented in owl::TApplication.

Definition at line 202 of file msgthred.cpp.

References TRACEX.

Member Data Documentation

◆ BreakMessageLoop

bool owl::TMsgThread::BreakMessageLoop
protected

Message loop is broken via WM_QUIT.

Definition at line 106 of file msgthred.h.

◆ LoopRunning

bool owl::TMsgThread::LoopRunning
protected

Track if the loop is running.

Definition at line 110 of file msgthred.h.

◆ MessageLoopResult

int owl::TMsgThread::MessageLoopResult
protected

Return value from message loop.

Definition at line 107 of file msgthred.h.


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