Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_M_Thread Class Reference

Mix-in class for using threads in CPLAT. For each object that needs to run in a separate thread, mix-in this class and override the Run() method, which is the routine that does the actual work.

List of all members.

Control

SInt32 GetPriority ()
SInt32 SetPriority (SInt32 newVal)
void Suspend ()
void Finish ()
void Resume ()
bool IsSuspend ()
bool HasCompleted ()
void Kill ()
static void YieldThread (CP_M_Thread *inThread=NULL)
static void SleepThread (UInt32 numMilliSecs)

Public Types

enum  {
  kPriorityIdle = THREAD_PRIORITY_IDLE, kPriorityLowest = THREAD_PRIORITY_LOWEST, kPriorityBelowNormal = THREAD_PRIORITY_BELOW_NORMAL, kPriorityNormal = THREAD_PRIORITY_NORMAL,
  kPriorityHighest = THREAD_PRIORITY_HIGHEST, kPriorityCritical = THREAD_PRIORITY_TIME_CRITICAL, kPriorityError, kPriorityLowest = THREAD_PRIORITY_LOWEST,
  kPriorityBelowNormal = THREAD_PRIORITY_BELOW_NORMAL, kPriorityNormal = THREAD_PRIORITY_NORMAL, kPriorityHighest = THREAD_PRIORITY_HIGHEST, kPriorityCritical = THREAD_PRIORITY_TIME_CRITICAL,
  kPriorityError
}

Public Member Functions

Constructor / Destructor
 CP_M_Thread ()
 Constructor.
virtual ~CP_M_Thread ()
 Destructor.
Setup
void SetupThread ()

Protected Member Functions

Running
virtual UInt32 Run ()=0
Getters
ThreadID GetID ()
DWORD GetID ()

Protected Attributes

ThreadID fThreadID
HANDLE fThreadHandle
unsigned fThreadID
bool fThreadSuspend

Static Private Member Functions

Running
static pascal void * ThreadEntry (void *inParameter)
static unsigned WINAPI ThreadEntry (LPVOID inParameter)

Private Attributes

bool fHasCompleted
bool * fDestructed


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
kPriorityIdle 
kPriorityLowest 
kPriorityBelowNormal 
kPriorityNormal 
kPriorityHighest 
kPriorityCritical 
kPriorityError 
kPriorityLowest 
kPriorityBelowNormal 
kPriorityNormal 
kPriorityHighest 
kPriorityCritical 
kPriorityError 


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_M_Thread::CP_M_Thread  ) 
 

Constructor.

CP_M_Thread::~CP_M_Thread  )  [virtual]
 

Destructor.


Member Function Documentation

void CP_M_Thread::YieldThread CP_M_Thread inThread = NULL  )  [static]
 

Allow other threads time to operate.

Parameters:
inThread A CP_M_Thread object that we want to yield time to or NULL to yield to any other thread.
Exceptions:
none 
Returns:
void

void CP_M_Thread::SleepThread UInt32  numMilliSecs  )  [static]
 

Put this thread to sleep for the passed in number of milliseconds.

Parameters:
numMmilliSecs Number of milliseconds to put this thread to sleep for.
Exceptions:
none 
Returns:
void

SInt32 CP_M_Thread::GetPriority  ) 
 

Get the priority of this thread.

Exceptions:
none 
Returns:
SInt32 Returns the priority of this thread.

SInt32 CP_M_Thread::SetPriority SInt32  newVal  ) 
 

Set the priority of this thread, and returns the priority

Parameters:
newVal The new priority of this thread
Exceptions:
none 
Returns:
SInt32 Returns the priority of this thread.

void CP_M_Thread::Suspend  ) 
 

Suspend the thread.

Exceptions:
none 
Returns:
void

void CP_M_Thread::Finish  ) 
 

Mark that we are done, so thread loops will finish.

Exceptions:
none 
Returns:
void

void CP_M_Thread::Resume  ) 
 

Resume a previously suspended thread.

Exceptions:
none 
Returns:
void

bool CP_M_Thread::IsSuspend  ) 
 

Return true if our thread is currently suspended.

Exceptions:
none 
Returns:
bool Returns true if the thread is currently suspended.

bool CP_M_Thread::HasCompleted  ) 
 

Return the status of the has completed flag to indicate if this thread has completed.

Exceptions:
none 
Returns:
bool True if the thread has completed.

void CP_M_Thread::Kill  ) 
 

Delete our thread.

Exceptions:
none 
Returns:
void

void CP_M_Thread::SetupThread  ) 
 

Setsup the thread with the underlying OS.

Exceptions:
none 
Returns:
void

virtual UInt32 CP_M_Thread::Run  )  [protected, pure virtual]
 

Subclasses must override this to provide the routine that does the work in the tread.

Exceptions:
none 
Returns:
UInt32 Result of the thread.

ThreadID CP_M_Thread::GetID  )  [protected]
 

Return the thread id, MacOS version.

Exceptions:
none 
Returns:
ThreadID MacOS id of the thread.

DWORD CP_M_Thread::GetID  )  [protected]
 

Return the thread id, Windows version.

Exceptions:
none 
Returns:
ThreadID MacOS id of the thread.

static pascal void* CP_M_Thread::ThreadEntry void *  inParameter  )  [static, private]
 

static unsigned WINAPI CP_M_Thread::ThreadEntry LPVOID  inParameter  )  [static, private]
 


Member Data Documentation

bool CP_M_Thread::fHasCompleted [private]
 

bool* CP_M_Thread::fDestructed [private]
 

ThreadID CP_M_Thread::fThreadID [protected]
 

HANDLE CP_M_Thread::fThreadHandle [protected]
 

A MacOS ThreadID for this thread.

unsigned CP_M_Thread::fThreadID [protected]
 

Windows thread HANDLE for this thread.

bool CP_M_Thread::fThreadSuspend [protected]
 

Thread id for the thread.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:01:49 2005 for CPLAT by  doxygen 1.4.0