Torque2D Reference
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Thread Class Reference

#include <thread.h>

Public Member Functions

 Thread (ThreadRunFunction func=0, void *arg=0, bool start_thread=true, bool autodelete=false)
 
virtual ~Thread ()
 
void start ()
 
void stop ()
 Ask a thread to stop running. More...
 
bool join ()
 Block until the thread stops running. More...
 
bool checkForStop ()
 
virtual void run (void *arg=0)
 
bool isAlive ()
 Returns true if the thread is running. More...
 
U32 getId ()
 Returns the platform specific thread id for this thread. More...
 

Public Attributes

bool autoDelete
 If set, the thread will delete itself once it has finished running. More...
 

Protected Attributes

PlatformThreadData * mData
 
bool shouldStop
 

Constructor & Destructor Documentation

Thread ( ThreadRunFunction  func = 0,
void *  arg = 0,
bool  start_thread = true,
bool  autodelete = false 
)

Create a thread.

Parameters
funcThe starting function for the thread.
argData to be passed to func, when the thread starts.
start_threadWhether to start the Thread immediately.
virtual ~Thread ( )
virtual

Destroy a thread. The thread MUST be allowed to exit before it is destroyed.

Member Function Documentation

bool checkForStop ( )
inline

Threads may call checkForStop() periodically to check if they've been asked to stop. As soon as checkForStop() returns true, the thread should clean up and return.

U32 getId ( )

Returns the platform specific thread id for this thread.

bool isAlive ( )

Returns true if the thread is running.

bool join ( )

Block until the thread stops running.

virtual void run ( void *  arg = 0)
virtual

Run the Thread's entry point function. Override this method in a subclass of Thread to create threaded code in an object oriented way, and without passing a function ptr to Thread(). Also, you can call this method directly to execute the thread's code in a non-threaded way.

void start ( )

Start a thread. Sets shouldStop to false and calls run() in a new thread of execution.

void stop ( )
inline

Ask a thread to stop running.

Member Data Documentation

bool autoDelete

If set, the thread will delete itself once it has finished running.

PlatformThreadData* mData
protected
bool shouldStop
protected

Used to signal threads need to stop. Threads set this flag to false in start()


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