Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
Thread Class Reference#include <Thread.h>
Inheritance diagram for Thread:
![]() Detailed DescriptionProvides a nice wrapping of pthreads library.If you need to provide cleanup functions on stop(), cancelled(), etc., you should override the destructor to stop and join so that you can be assured that your cleanup will be called if the thread is auto-destructed by going out of scope Definition at line 68 of file Thread.h.
Member Typedef Documentation
Constructor & Destructor Documentation
don't call, not a well defined operation
Member Function Documentation
requests that the thread be started, if not already running (you need to create a separate instances if you want to run multiple copies)
Reimplemented in PollThread. Definition at line 63 of file Thread.cc. Referenced by MessageQueueStatusThread::addStatusListener(), MessageReceiver::MessageReceiver(), MessageQueueStatusThread::setMessageQueue(), and PollThread::start().
sends a signal to the thread which will interrupt any sleep calls (and trigger interrupted() to be called within the thread)
Definition at line 87 of file Thread.cc. Referenced by stop().
requests that the thread be stopped gracefully, if running. A cancel flag is sent, and the thread will be stopped at next cancel point, defined by whenever testCancel(), or a set of other system functions, are called. See your system's pthread_testcancel() manual page for a list of cancel points. This function may imply a call to interrupt() on systems which have extremely limited system cancel points. Currently, this consists of only Mac OS X. There is hope that additional cancellation points will be enabled on this system: http://lists.apple.com/archives/darwin-kernel/2004/Jan/msg00032.html
Reimplemented in MessageQueueStatusThread, and MessageReceiver. Definition at line 95 of file Thread.cc. Referenced by MessageReceiver::stop(), MessageQueueStatusThread::stop(), PollThread::~PollThread(), and ~Thread().
sends a SIGUSR1 to the thread, breaking its execution, but still allowing handle_exit (and thus cancelled()) to be called. Beware if your thread uses mutual exclusion locks, this can cause the thread to terminate while still holding locks
sends a signal to the thread
Definition at line 133 of file Thread.cc. Referenced by interrupt(), kill(), and murder().
blocks calling thread until this Thread has terminated, via one means or another; return value is final return value by the thread
Definition at line 146 of file Thread.cc. Referenced by MessageReceiver::finish(), MessageReceiver::~MessageReceiver(), PollThread::~PollThread(), and ~Thread().
indicates whether start() has been called (but may be some delay before isRunning() is true...)
Definition at line 109 of file Thread.h. Referenced by MessageQueueStatusThread::addStatusListener(), MessageReceiver::finish(), MessageQueueStatusThread::removeStatusListener(), MessageQueueStatusThread::~MessageQueueStatusThread(), MessageReceiver::~MessageReceiver(), and PollThread::~PollThread().
indicates whether the thread is currently alive and running, implies isStarted()
Definition at line 112 of file Thread.h. Referenced by interrupt(), and sendSignal().
returns the Thread object for the current thread (or NULL for the main thread)
Definition at line 153 of file Thread.cc. Referenced by handle_exit(), handleInterrupt(), popNoCancel(), pushNoCancel(), Thread(), and warnSelfUndestructed().
should be called whenever a critical section has been entered (i.e. mutex obtained) -- prevents cancel from occurring until popNoCancel() is called
Definition at line 267 of file Thread.cc. Referenced by MessageReceiver::runloop().
should be called whenever a critical section is left (i.e. mutex released) -- if it was the last one, tests cancellability as well
Definition at line 287 of file Thread.cc. Referenced by MessageReceiver::runloop().
called by launch() when thread is first entered, return false to cancel launch (set returnValue as well if you care)
Reimplemented in MessageQueueStatusThread, and MessageReceiver. Definition at line 134 of file Thread.h. Referenced by launch(), MessageReceiver::launched(), and MessageQueueStatusThread::launched().
called by launch() once the thread has been set up; when this returns, the thread ends, see runloop() Default implementation repeatedly calls runloop(), usleep(), and testCancel(). If you override, you should also be sure to call testCancel occasionally in order to support stop() If function returns a value, that value overrides returnValue. If cancel occurs, returnValue is used. Reimplemented in MessageQueueStatusThread, and PollThread. Definition at line 74 of file Thread.cc. Referenced by launch().
override this as a convenient way to define your thread -- return the number of *micro*seconds to sleep before the next call; return -1U to indicate end of processing
Reimplemented in MessageReceiver. Definition at line 141 of file Thread.h. Referenced by PollThread::poll(), and run().
called when handle_exit() is triggered, either by the thread being cancelled, or when run() has returned voluntarily
Reimplemented in MessageQueueStatusThread. Definition at line 143 of file Thread.h. Referenced by handle_exit(), and warnSelfUndestructed().
checks to see if stop() has been called, and if so, will exit the thread (passing through handle_exit() first)
Definition at line 179 of file Thread.cc. Referenced by handleInterrupt(), run(), PollThread::run(), and MessageQueueStatusThread::run().
thread entry point -- calls launched() on the thread (as indicated by msg), and then run()
Definition at line 188 of file Thread.cc. Referenced by start().
indicates the thread is exiting, either voluntary (run() returned), stop(), or kill() -- calls cancelled() for the thread as indicated by th
Definition at line 243 of file Thread.cc. Referenced by handle_launch_signal(), and launch().
called by handleInterrupt() in target thread following call to interrupt(), assuming thread has not been cancelled (which can intercept the interrupt)
Reimplemented in PollThread. Definition at line 157 of file Thread.h. Referenced by handleInterrupt().
called by SIGALRM signal handler installed by interrupt() just before it posts the corresponding SIGALRM tests for thread cancel condition before calling on to interrupted() Reimplemented in PollThread. Definition at line 312 of file Thread.cc. Referenced by interrupt().
emit a warning that the last thread exited while the self-pointer thread-specific key still exists (need to call releaseMainThread() or handle_exit())
Definition at line 325 of file Thread.cc. Referenced by initMainThread().
Member Data Documentation
set to true once start() has been called, set back to false by handle_exit(), or by murder() itself
Definition at line 169 of file Thread.h. Referenced by handle_exit(), isStarted(), murder(), sendSignal(), start(), stop(), warnSelfUndestructed(), and ~Thread().
set to true once launch() has been called, set back to false by handle_exit(), or by murder() itself
Definition at line 171 of file Thread.h. Referenced by handle_exit(), isRunning(), launch(), murder(), sendSignal(), MessageQueueStatusThread::setMessageQueue(), stop(), and warnSelfUndestructed().
indicates the value to be returned by the thread entry point (and thus passed back to join()) -- set this in runloop() or launched(), overridden by run()'s return value
Definition at line 173 of file Thread.h. Referenced by launch(), run(), and PollThread::run().
depth of the pushNoCancel() stack
Definition at line 175 of file Thread.h. Referenced by handle_exit(), handleInterrupt(), launch(), popNoCancel(), pushNoCancel(), testCancel(), and warnSelfUndestructed().
cancel status at root of no-cancel stack (may be no-cancel through and through)
Definition at line 177 of file Thread.h. Referenced by launch(), popNoCancel(), and pushNoCancel().
indicates a common group of threads, inherited from the thread which created this one, default NULL if created from main thread
Definition at line 180 of file Thread.h. Referenced by getGroup(), setGroup(), and Thread().
The documentation for this class was generated from the following files: |
Tekkotsu v4.0 |
Generated Thu Nov 22 00:58:44 2007 by Doxygen 1.5.4 |