|
| PosixThread (int pri=0, size_t stack=0) |
|
void | signalThread (int signo) |
| Delivers a Posix signal to the current thread. More...
|
|
int | start (Semaphore *start=0) |
| When a new thread is created, it does not begin immediate execution. More...
|
|
int | detach (Semaphore *start=0) |
| Start a new thread as "detached". More...
|
|
Thread * | getParent (void) |
| Gets the pointer to the Thread class which created the current thread object. More...
|
|
void | suspend (void) |
| Suspends execution of the selected thread. More...
|
|
void | resume (void) |
| Resumes execution of the selected thread. More...
|
|
Cancel | getCancel (void) |
| Used to retrieve the cancellation mode in effect for the selected thread. More...
|
|
bool | isRunning (void) const |
| Verifies if the thread is still running or has already been terminated but not yet deleted. More...
|
|
bool | isDetached (void) const |
| Check if this thread is detached. More...
|
|
void | join (void) |
| Blocking call which unlocks when thread terminates. More...
|
|
bool | isThread (void) const |
| Tests to see if the current execution context is the same as the specified thread object. More...
|
|
cctid_t | getId (void) const |
| Get system thread numeric identifier. More...
|
|
const char * | getName (void) const |
| Get the name string for this thread, to use in debug messages. More...
|
|
|
static void | sigInstall (int signo) |
| Install a signal handler for use by threads and the OnSignal() event notification handler. More...
|
|
static Thread * | get (void) |
|
static void | setStack (size_t size=0) |
| Set base stack limit before manual stack sizes have effect. More...
|
|
static void | sleep (timeout_t msec) |
| A thread-safe sleep call. More...
|
|
static void | yield (void) |
| Yields the current thread's CPU time slice to allow another thread to begin immediate execution. More...
|
|
static Throw | getException (void) |
| Get exception mode of the current thread. More...
|
|
static void | setException (Throw mode) |
| Set exception mode of the current thread. More...
|
|
static Cancel | enterCancel (void) |
| This is used to help build wrapper functions in libraries around system calls that should behave as cancellation points but don't. More...
|
|
static void | exitCancel (Cancel cancel) |
| This is used to restore a cancel block. More...
|
|
|
void | signalParent (signo_t signo) |
| In the Posix version of Common C++, this can be used to send a signal into the parent thread of the current object. More...
|
|
void | signalMain (signo_t signo) |
| In the Posix version of Common C++, this can be used to send a signal into the main application thread. More...
|
|
virtual void | onTimer (void) |
| A derivable method to call when a SIGALRM is being delivered to a specific thread. More...
|
|
virtual void | onHangup (void) |
| A derived method to handle hangup events being delivered to a specific thread. More...
|
|
virtual void | onException (void) |
| A derived method to call when a SIGABRT is being delivered to a specific thread. More...
|
|
virtual void | onDisconnect (void) |
| A derived method to call when a SIGPIPE is being delivered to a specific thread. More...
|
|
virtual void | onPolling (void) |
| A derived method to handle asynchronous I/O requests delivered to the specified thread. More...
|
|
virtual void | onSignal (int) |
| A derivable method to call for delivering a signal event to a specified thread. More...
|
|
void | setTimer (timeout_t timer, bool periodic=false) |
| Used to specify a timeout event that can be delivered to the current thread via SIGALRM. More...
|
|
timeout_t | getTimer (void) const |
| Gets the time remaining for the current threads timer before it expires. More...
|
|
void | endTimer (void) |
| Terminates the timer before the timeout period has expired. More...
|
|
void | setSignal (int signo, bool active) |
| Used to enable or disable a signal within the current thread. More...
|
|
pthread_attr_t * | getPthreadAttrPtr (void) |
| Access to pthread_attr structure this allows setting/modifying pthread attributes not covered in the platform independant Thread constructor, e.g. More...
|
|
pthread_t | getPthreadId (void) |
| Get pthread_t of underlying posix thread (useful for debugging/logging) More...
|
|
void | setName (const char *text) |
| Set the name of the current thread. More...
|
|
virtual void | run (void)=0 |
| All threads execute by deriving the Run method of Thread. More...
|
|
virtual void | final (void) |
| A thread that is self terminating, either by invoking exit() or leaving it's run(), will have this method called. More...
|
|
virtual void | initial (void) |
| The initial method is called by a newly created thread when it starts execution. More...
|
|
virtual void * | getExtended (void) |
| Since getParent() and getThread() only refer to an object of the Thread "base" type, this virtual method can be replaced in a derived class with something that returns data specific to the derived class that can still be accessed through the pointer returned by getParent() and getThread(). More...
|
|
virtual void | notify (Thread *) |
| When a thread terminates, it now sends a notification message to the parent thread which created it. More...
|
|
void | exit (void) |
| Used to properly exit from a Thread derived run() or initial() method. More...
|
|
void | sync (void) |
| Used to wait for a join or cancel, in place of explicit exit. More...
|
|
bool | testCancel (void) |
| test a cancellation point for deferred thread cancellation. More...
|
|
void | setCancel (Cancel mode) |
| Sets thread cancellation mode. More...
|
|
void | setSuspend (Suspend mode) |
| Sets the thread's ability to be suspended from execution. More...
|
|
void | terminate (void) |
| Used by another thread to terminate the current thread. More...
|
|
void | clrParent (void) |
| clear parent thread relationship. More...
|
|
Definition at line 1537 of file thread.h.
virtual void Thread::final |
( |
void |
| ) |
|
|
protectedvirtualinherited |
A thread that is self terminating, either by invoking exit() or leaving it's run(), will have this method called.
It can be used to self delete the current object assuming the object was created with new on the heap rather than stack local, hence one may often see final defined as "delete this" in a derived thread class. A final method, while running, cannot be terminated or cancelled by another thread. Final is called for all cancellation type (even immediate).
You can safe delete thread ("delete this") class on final, but you should exit ASAP (or do not try to call CommonC++ methods...)
- Note
- A thread cannot delete its own context or join itself. To make a thread that is a self running object that self-deletes, one has to detach the thread by using detach() instead of start().
- See Also
- exit
-
run
Reimplemented in ThreadQueue.
virtual void Thread::initial |
( |
void |
| ) |
|
|
protectedvirtualinherited |
The initial method is called by a newly created thread when it starts execution.
This method is ran with deferred cancellation disabled by default. The Initial method is given a separate handler so that it can create temporary objects on it's own stack frame, rather than having objects created on run() that are only needed by startup and yet continue to consume stack space.
- See Also
- run
-
final
Reimplemented in TCPSession, and UnixSession.
A thread-safe sleep call.
On most Posix systems, "sleep()" is implimented with SIGALRM making it unusable from multipe threads. Pthread libraries often define an alternate "sleep" handler such as usleep(), nanosleep(), or nap(), that is thread safe, and also offers a higher timer resolution.
- Parameters
-
msec | timeout in milliseconds. |
When a new thread is created, it does not begin immediate execution.
This is because the derived class virtual tables are not properly loaded at the time the C++ object is created within the constructor itself, at least in some compiler/system combinations. The thread can either be told to wait for an external semaphore, or it can be started directly after the constructor completes by calling the start() method.
- Returns
- error code if execution fails.
- Parameters
-
start | optional starting semaphore to alternately use. |