Functions | |
void | sleep (UInt32 milliSeconds) |
Suspend execution of the current thread until the given number of milliSeconds have elapsed. | |
void | yield () |
Voluntarily yield to the processor giving the next thread in the chain the opportunity to run. | |
static void * | threadStarter (void *arg) |
static void | initializeTheKey () |
int | createThread (Thread_t &handle, ThreadFunction func, void *funcParm, UInt32 threadFlags) |
Starts a thread running the given function. | |
void | exitThread (Thread_t &handle, Int32 rval) |
Exit thread method. | |
UInt64 | thread_t_ToUInt64 (Thread_t thr) |
Convert a Thread_t to an UInt64. | |
void | destroyThread (Thread_t &handle) |
Destroy any resources associated with a thread that was created with the createThread method. | |
int | setThreadDetached (Thread_t &handle) |
Set a thread that was previously in the joinable state to a detached state. | |
int | joinThread (Thread_t &handle, Int32 &rval) |
Join a thread that has been previously set to joinable. | |
void | testCancel () |
Test if this thread has been cancelled. | |
void | saveThreadInTLS (void *pTheThread) |
void | sendSignalToThread (Thread_t threadID, int signo) |
void | cancel (Thread_t threadID) |
bool | sameThreads (const volatile Thread_t &handle1, const volatile Thread_t &handle2) |
Check two platform dependant thread types for equality. | |
Thread_t | currentThread () |
void | memoryBarrier () |
Deprecated because no code should need to use this, and if some does it should be rewritten to use the other thread primitives. | |
Variables | |
default_stack_size | g_theDefaultStackSize |
pthread_once_t | once_control = PTHREAD_ONCE_INIT |
pthread_key_t | theKey |
It also contains other misellaneous functions which are useful for synchronization and threads. It is essentially an abstraction layer over a thread implementation.
|
Definition at line 388 of file ThreadImpl.cpp. References BLOCXX_THROW. Referenced by BLOCXX_NAMESPACE::Thread::cancel(). |
|
Starts a thread running the given function.
Definition at line 249 of file ThreadImpl.cpp. References BLOCXX_THREAD_FLG_JOINABLE, needsSetting, threadStarter(), and val. Referenced by BLOCXX_NAMESPACE::Thread::start(). |
|
Definition at line 108 of file ThreadImpl.hpp. Referenced by BLOCXX_NAMESPACE::RWLocker::getReadLock(), BLOCXX_NAMESPACE::RWLocker::getWriteLock(), and BLOCXX_NAMESPACE::RWLocker::releaseReadLock(). |
|
Destroy any resources associated with a thread that was created with the createThread method.
Definition at line 311 of file ThreadImpl.cpp. Referenced by BLOCXX_NAMESPACE::Thread::~Thread(). |
|
Exit thread method. This method is called everytime a thread exits. When the POSIX threads are being used, pthread_exit is called. This function does not return.
Definition at line 281 of file ThreadImpl.cpp. Referenced by BLOCXX_NAMESPACE::Thread::threadRunner(). |
|
Definition at line 229 of file ThreadImpl.cpp. References theKey. Referenced by saveThreadInTLS(), and testCancel(). |
|
Join a thread that has been previously set to joinable. It is Assumed that if the thread has already terminated, this method will still succeed and return immediately.
Definition at line 332 of file ThreadImpl.cpp. Referenced by BLOCXX_NAMESPACE::Thread::join(). |
|
Deprecated because no code should need to use this, and if some does it should be rewritten to use the other thread primitives.
Definition at line 160 of file ThreadImpl.hpp. |
|
Check two platform dependant thread types for equality.
Definition at line 88 of file ThreadImpl.hpp. Referenced by BLOCXX_NAMESPACE::RWLocker::getReadLock(), BLOCXX_NAMESPACE::RWLocker::getWriteLock(), BLOCXX_NAMESPACE::RWLocker::releaseReadLock(), and BLOCXX_NAMESPACE::sameId(). |
|
Definition at line 368 of file ThreadImpl.cpp. References BLOCXX_THROW, initializeTheKey(), once_control, and theKey. Referenced by BLOCXX_NAMESPACE::Thread::threadRunner(). |
|
Definition at line 379 of file ThreadImpl.cpp. References BLOCXX_THROW. Referenced by BLOCXX_NAMESPACE::Thread::cooperativeCancel(), and BLOCXX_NAMESPACE::Thread::definitiveCancel(). |
|
Set a thread that was previously in the joinable state to a detached state. This will allow the threads resources to be released upon termination without being joined. A thread that is in the detached state can no longer be joined.
Definition at line 317 of file ThreadImpl.cpp. |
|
Suspend execution of the current thread until the given number of milliSeconds have elapsed.
Definition at line 84 of file ThreadImpl.cpp. References BLOCXX_NAMESPACE::Select::select(), and testCancel(). Referenced by BLOCXX_NAMESPACE::milliSleep(), BLOCXX_NAMESPACE::secSleep(), BLOCXX_NAMESPACE::Thread::sleep(), and yield(). |
|
Test if this thread has been cancelled. If so, a ThreadCancelledException will be thrown. DO NOT catch this exception. ThreadCancelledException is not derived from anything. Do not write code like this: try { //... } catch (...) { // swallow all exceptions } Instead do this: try { //... } catch (ThreadCancelledException&) { throw; } catch (std::exception& e) { // handle the exception } The only place ThreadCancelledException should be caught is in Thread::threadRunner(). main() shouldn't need to catch it, as the main thread of an application should never be cancelled. The main thread shouldn't need to ever call testCancel. Note that this method is staic, and it will check the the current running thread has been cacelled. Thus, you can't call it on an object that doesn't represent the current running thread and expect it to work. Definition at line 347 of file ThreadImpl.cpp. References initializeTheKey(), BLOCXX_NAMESPACE::Thread::m_cancelLock, BLOCXX_NAMESPACE::Thread::m_cancelRequested, once_control, and theKey. Referenced by BLOCXX_NAMESPACE::noIntrWaitPid(), BLOCXX_NAMESPACE::Select::selectRWPoll(), BLOCXX_NAMESPACE::Select::selectRWSelect(), sleep(), BLOCXX_NAMESPACE::Thread::testCancel(), and yield(). |
|
Convert a Thread_t to an UInt64. This hides platform dependencies like that fact that on some platforms (e.g linux) Thread_t is integral type, and can therefor be static_cast<>ed to unsigned long, but on other platforms, like FreeBSD, Thread_t is void*, or something else, and reinterpret_cast<> (hopefully that works ...) must be used. Definition at line 302 of file ThreadImpl.cpp. References BLOCXX_THREAD_CONVERTER. |
|
Definition at line 154 of file ThreadImpl.cpp. References BLOCXX_ASSERT. Referenced by createThread(). |
|
Voluntarily yield to the processor giving the next thread in the chain the opportunity to run.
Definition at line 133 of file ThreadImpl.cpp. References sleep(), and testCancel(). Referenced by BLOCXX_NAMESPACE::Thread::yield(). |
|
Definition at line 223 of file ThreadImpl.cpp. |
|
Definition at line 225 of file ThreadImpl.cpp. Referenced by saveThreadInTLS(), and testCancel(). |
|
Definition at line 226 of file ThreadImpl.cpp. Referenced by initializeTheKey(), saveThreadInTLS(), and testCancel(). |