ReplicaNet and RNLobby
1
|
#include <Thread.h>
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 |
This Thread class handles creating a class that can be automatically threaded. A threaded class inherits methods from ThreadClass.
Thread | ( | ) |
The ctor performs some basic initialisation
|
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.
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()
threaded_class | the pointer to the class that inherits from ThreadClass |
|
static |
This is a static method where the class starts its thread from
thread_class | the threaded class pointer |
|
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
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.
processor | The 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.