#include <base_thread.hh>

Public Types | |
| enum | ePriority { ePriority_DEFAULT, ePriority_LOW, ePriority_HIGH } |
| typedef void(* | ThreadFunc )(long) |
| the C function where a new thread begins. | |
| typedef volatile pthread_t | AtomicTid |
Public Member Functions | |
| Tid | Run (const RunArgs &runArgs) |
| void | Yield (void) |
| void | Sleep (Milliseconds millisecs) |
| bool | Wait (Tid tid) |
| void | Wait (Condition &condition) |
| void | Awaken (Condition &condition) |
| uint | Cnt (void) |
| bool | IfMain (void) |
| Tid | GetTid (void) |
| void * | SuballocateThreadMemory (uint bytes) |
Private Member Functions | |
| Thread (void) | |
| ~Thread () | |
| void | InitPthreadAttr () |
| CLASS_METHOD void * | Run2 (void *runArgs) |
| void | Run3 (const RunArgs &runArgs) |
| void | NewThreadMemory (const uint threadMemorySize) |
| void | DeleteThreadMemory (void) |
Private Attributes | |
| bool | mValid |
| Atomic::Int | mThreadCnt |
| how many threads are active | |
| Tid | mMainTid |
| TID of main thread. | |
| vector< pthread_attr_t > | mPthreadAttr |
| pthread attributes such as priority etc | |
| pthread_key_t | mThreadMemoryKey |
| key to per-thread memory block on heap | |
| CLASS_VAR uint | msDefaultThreadMemorySize = DEFAULT_THREAD_MEMORY_SIZE |
| default arg for Run() | |
Friends | |
| class | Global |
| void * | SuballocateThreadMemory (const uint bytes) |
Classes | |
| class | Condition |
| Wait-on-condition. More... | |
| struct | RunArgs |
| Args for Thread::Run(). More... | |
| struct | Tid |
| Thread ID (opaque). More... | |
Ironically, the Thread class itself should be Threadable.
| typedef void(* base::Thread::ThreadFunc)(long) |
the C function where a new thread begins.
| typedef volatile pthread_t base::Thread::AtomicTid |
| base::Thread::Thread | ( | void | ) | [private] |
ctor.
| base::Thread::~Thread | ( | ) | [private] |
| Thread::Tid base::Thread::Run | ( | const RunArgs & | runArgs | ) |
Spawn a thread to execute a C function.
Thread::Run() --> Thread::Run2() --> Thread::Run3() --> target function
NOTE: This must be re-entrant.
| void base::Thread::Yield | ( | void | ) |
Yield CPU.
| void base::Thread::Sleep | ( | Milliseconds | millisecs | ) |
Sleep.
| bool base::Thread::Wait | ( | Tid | tid | ) |
Wait for a thread to finish (join).
| void base::Thread::Wait | ( | Condition & | condition | ) |
| void base::Thread::Awaken | ( | Condition & | condition | ) |
| uint base::Thread::Cnt | ( | void | ) |
| bool base::Thread::IfMain | ( | void | ) |
| Thread::Tid base::Thread::GetTid | ( | void | ) |
| void* base::Thread::SuballocateThreadMemory | ( | uint | bytes | ) |
| void base::Thread::InitPthreadAttr | ( | void | ) | [private] |
For ctor. Pre-initialize POSIX thread attributes. POSIX thread attributes were designed for reuse. pthread_setschedprio() is rarely implemented (Fedora 3 [2004] lacks it).
| void * base::Thread::Run2 | ( | void * | runArgs | ) | [private] |
| void base::Thread::Run3 | ( | const RunArgs & | runArgs | ) | [private] |
| void base::Thread::NewThreadMemory | ( | const uint | threadMemorySize | ) | [private] |
Allocate heap memory for this thread. Used by PerThreadPtr. Applies to main thread too.
| void base::Thread::DeleteThreadMemory | ( | void | ) | [private] |
friend class Global [friend] |
| void * base::Thread::SuballocateThreadMemory | ( | const uint | bytes | ) | [friend] |
Suballocate thread memory.
bool base::Thread::mValid [private] |
Atomic::Int base::Thread::mThreadCnt [private] |
how many threads are active
Tid base::Thread::mMainTid [private] |
TID of main thread.
vector<pthread_attr_t> base::Thread::mPthreadAttr [private] |
pthread attributes such as priority etc
pthread_key_t base::Thread::mThreadMemoryKey [private] |
key to per-thread memory block on heap
uint base::Thread::msDefaultThreadMemorySize = DEFAULT_THREAD_MEMORY_SIZE [private] |
default arg for Run()
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:19 2007