zeus::TThread Class Reference

#include <Thread.h>

Inheritance diagram for zeus::TThread:

zeus::TZObject zeus::IThread zeus::IZUnknown zeus::IZUnknown zeus::TAbstractSkel zeus::TAbstractSkel::TClientHandlerThread zeus::TPeerFinder zeus::TPeerProvider zeus::TCommPipe_Skel zeus::TMessagePool_Skel zeus::TMessageServerConnection_Skel zeus::TNamedContext_Skel

List of all members.

Public Types

enum  EPriority {
  etNormal = 0, etLow = 1, etHigh = 2, etLower = 3,
  etHigher = 4, etTimeCritical = 5
}

Public Member Functions

 TThread (EPriority ePriority=etNormal)
 TThread (IRunnable &rObj, EPriority ePriority=etNormal)
EPriority getPriority () const
void setPriority (EPriority ePriority)
virtual void kill (Float64 dTimeOut=0)
virtual bool isAlive () const
virtual bool isDead () const
virtual void resume ()
virtual bool signalizeStop (Float64 dTimeOut=5.0)
virtual bool start ()
virtual void suspend ()
virtual bool yield ()
virtual Retval postObject (ISynchronizeObject &rObject, bool bWaitForCompletion)
virtual bool MQUALIFIER isInterrupted () const
virtual Uint MQUALIFIER getThreadID () const
virtual Retval MQUALIFIER askForInterface (Uint uiInterfaceID, IZUnknown *&rpIface)
virtual void MQUALIFIER addRef () const
virtual void MQUALIFIER release () const

Static Public Member Functions

static void sleep (const Float &rfDelay)

Protected Member Functions

virtual ~TThread ()
virtual void execute ()
virtual void onTerminated ()
virtual void onStarted ()

Protected Attributes

bool m_bInterrupted
 Flag to check if the thread should terminate.
TThreadMessageQueuem_rQueue
 Message queue of the thread.


Detailed Description

This class wrapps a kernel thread object. It provides a simple and convinient interface to the API functions using object oriented design. Lots of tricky code is wrapped to avoid deadlocks and other nasty behaviours just using API functions.

Member Enumeration Documentation

Type of thread priority

Enumerator:
etNormal 
etLow 
etHigh 
etLower 
etHigher 
etTimeCritical 


Constructor & Destructor Documentation

TThread::TThread ( EPriority  ePriority = etNormal  ) 

Creates a thread

Parameters:
ePriority : Thread priority

TThread::TThread ( IRunnable rObj,
EPriority  ePriority = etNormal 
)

Creates a thread using an external object as executing

Parameters:
rObj : Object for execution
ePriority : Thread priority

TThread::~TThread (  )  [protected, virtual]

Destroys the thread


Member Function Documentation

TThread::EPriority zeus::TThread::getPriority (  )  const [inline]

returns the priority of the thread

void TThread::setPriority ( EPriority  ePriority  ) 

sets a new priority of the thread

Parameters:
ePriority : new priority

void TThread::sleep ( const Float &  rfDelay  )  [static]

Suspends the thread for a given time in seconds

void TThread::kill ( Float64  dTimeOut = 0  )  [virtual]

Terminates the thread. If time out is not zero, this method will wait, until the thread terminats itself. If timeout occures, the thread will be forced to terminate. This might cause ressource leaks.

Parameters:
dTimeOut : Time out

Reimplemented in zeus::TAbstractSkel, and zeus::TAbstractSkel::TClientHandlerThread.

bool zeus::TThread::isAlive (  )  const [inline, virtual]

Inverse of isDead

bool zeus::TThread::isDead (  )  const [inline, virtual]

Checks if the thread is dead. The thread is dead if never start() has been called or after its termination using signalizeStop() or kill().

Return values:
true : Thread is not running
false : Thread still runs

void TThread::resume (  )  [virtual]

This starts a stopped thread.

bool TThread::signalizeStop ( Float64  dTimeOut = 5.0  )  [virtual]

Sets the interrupped signal.

Note:
the minimal time slice is about 0.1 sec.

Reimplemented in zeus::TPeerFinder, and zeus::TPeerProvider.

bool TThread::start (  )  [virtual]

Starts the thread.

Return values:
true,: Thread created and successfully started
false,: Could not start the thread (OS error)

void TThread::suspend (  )  [virtual]

This stopps a thread. Using resume() the thread can be restarted

bool TThread::yield (  )  [virtual]

this method causes the OS to switch to an other thread (scheduling).

Return values:
true : yield has been performed
false,: could not yield thread

Retval TThread::postObject ( ISynchronizeObject rObject,
bool  bWaitForCompletion 
) [virtual]

this sends a message to the queue of the thread

Note:
This method could cause dead locks, if the thread is not started, but the bWaitForCompletion flag is set. Start the thread first
See also:
IThreadManager::postObject

bool MQUALIFIER zeus::TThread::isInterrupted (  )  const [inline, virtual]

See also:
IThread::isInterrupted

Implements zeus::IThread.

Uint MQUALIFIER TThread::getThreadID (  )  const [virtual]

See also:
IThread::getThreadID

Implements zeus::IThread.

virtual Retval MQUALIFIER zeus::TThread::askForInterface ( Uint  uiInterfaceID,
IZUnknown *&  rpIface 
) [virtual]

Reimplemented from zeus::TZObject.

Reimplemented in zeus::TPeerFinder.

virtual void MQUALIFIER zeus::TThread::addRef (  )  const [virtual]

See also:
IZUnknown::addRef

Reimplemented from zeus::TZObject.

Reimplemented in zeus::TPeerFinder.

virtual void MQUALIFIER zeus::TThread::release (  )  const [virtual]

See also:
IZUnknown::release

Reimplemented from zeus::TZObject.

Reimplemented in zeus::TPeerFinder.

void TThread::execute (  )  [protected, virtual]

This is the internal running method. Do not call this method directly

Reimplemented in zeus::TPeerFinder, zeus::TPeerProvider, zeus::TAbstractSkel, and zeus::TAbstractSkel::TClientHandlerThread.

virtual void zeus::TThread::onTerminated (  )  [inline, protected, virtual]

virtual void zeus::TThread::onStarted (  )  [inline, protected, virtual]


Member Data Documentation

Flag to check if the thread should terminate.

Message queue of the thread.


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


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Wed Oct 28 21:42:36 2009