ReplicaNet and RNLobby  1
Public Member Functions | Static Public Member Functions | Friends | List of all members
Thread Class Reference

#include <Thread.h>

Inheritance diagram for Thread:
Inheritance graph
[legend]

Public Member Functions

 Thread ()
 
virtual ~Thread ()
 
void Begin (ThreadClass *threaded_class)
 
void Terminate (void)
 
bool GetTerminated (void)
 
bool GetEverTerminated (void)
 
bool GetIsRunning (void) const
 
void SetPreferredProcessor (int processor=kReplicaNetPreferredProcessorOSChoice)
 
int GetPreferredProcessor (void)
 

Static Public Member Functions

static int CallThreadEntry (ThreadClass *thread_class)
 
static int GetCurrentProcessorNumber (void)
 
static size_t GetNumAllocated (void)
 
static size_t GetNumActive (void)
 

Friends

class ThreadClass
 

Detailed Description

This Thread class handles creating a class that can be automatically threaded. A threaded class inherits methods from ThreadClass.

Constructor & Destructor Documentation

Thread ( )

The ctor performs some basic initialisation

virtual ~Thread ( )
virtual

The dtor makes sure the thread is terminated. NOTE: If this class and the ThreadClass are part of the same class hierarchy then Terminate() must be explicitly called and not rely on this destructor.

Member Function Documentation

void Begin ( ThreadClass threaded_class)

This begins the thread in the specified ThreadClass class. This resets the GetTerminated() flag to false but does not reset GetEverTerminated(). Execution begins from ThreadClass::ThreadEntry()

Parameters
threaded_classthe pointer to the class that inherits from ThreadClass
static int CallThreadEntry ( ThreadClass thread_class)
static

This is a static method where the class starts its thread from

Parameters
thread_classthe threaded class pointer
static int GetCurrentProcessorNumber ( void  )
static

Gets the current processor number being used from the context of the calling thread, not the running context of this class since this is a static member.

bool GetEverTerminated ( void  )

Returns true if Terminate() was used at all and is not reset by Begin().

bool GetIsRunning ( void  ) const

Gets the execution status of the thread

Returns
return true if the thread is running
int GetPreferredProcessor ( void  )

Returns the value set by SetPreferredProcessor().

bool GetTerminated ( void  )

Returns true if Terminate() was used after the last Begin().

void SetPreferredProcessor ( int  processor = kReplicaNetPreferredProcessorOSChoice)

Sets the preferred processor this thread will execute on. This function is OS dependant.

Parameters
processorThe preferred processor. The default value is kReplicaNetPreferredProcessorOSChoice which allows the OS to choose a processor.
void Terminate ( void  )

Terminates the thread of the class bound to this Thread. The caller must not be in the context of the running thread.