VR-Link API Documentation for HLA 1.3
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
DtRunnable Class Reference

Declares the DtRunnable class for defining a object that can be run in a thread. More...

+ Inheritance diagram for DtRunnable:
+ Collaboration diagram for DtRunnable:

List of all members.

Public Member Functions

 DtRunnable ()
 Constructor.
virtual ~DtRunnable ()
 Destructor.
virtual void run ()=0
 Abstract function that will be called when the thread is started.
virtual void stop ()
 Function that will be called when the thread is told to stop.
bool timeToStop ()
 Time to stop function which returns TRUE if it is time to stop execution.

Protected Member Functions

void execute (volatile bool *stopFlag)
 Protected execute function which calls run.

Protected Attributes

volatile bool * myStopFlag
 Pointer to the stop flag.

Friends

class DtThreadStart

Detailed Description

Declares the DtRunnable class for defining a object that can be run in a thread.

DtRunnable is the defined interface for an object that can be run in a thread. To create a runnable class extend the DtRunnable class and implement the run function. It is important for code that can take considerable time to query the timeToStop() function in all loops, especially infinite loops. There is no safe way to terminate a thread thus to write multi-threading code it is important to allow the controlling thread to safely terminate a child thread.


Constructor & Destructor Documentation

Constructor.

virtual DtRunnable::~DtRunnable ( ) [virtual]

Destructor.


Member Function Documentation

void DtRunnable::execute ( volatile bool *  stopFlag) [protected]

Protected execute function which calls run.

virtual void DtRunnable::run ( ) [pure virtual]

Abstract function that will be called when the thread is started.

Implemented in DtIoServiceRunnable.

virtual void DtRunnable::stop ( ) [virtual]

Function that will be called when the thread is told to stop.

Override this function to stop without polling timeToStop.

Time to stop function which returns TRUE if it is time to stop execution.


Friends And Related Function Documentation

friend class DtThreadStart [friend]

Member Data Documentation

volatile bool* DtRunnable::myStopFlag [protected]

Pointer to the stop flag.


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

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)