My Project
|
#include <Thread.h>
Public Member Functions | |
void | start (void *arg) |
void | cancel () |
void | ping (void *arg) |
void | broadcastReady () |
void | broadcastDone () |
void | setRunState (bool state) |
bool | matchName (std::string compname) |
std::string | strName () |
Thread (THREAD_START(*startFn), THREAD_CLEAN(*cleanFn), THREAD_PING(*pingFn), std::string name, unsigned startOrder=0, unsigned cancelOrder=0) | |
Thread (THREAD_START(*startFn), THREAD_CLEAN(*cleanFn), THREAD_PING(*pingFn), std::string name, unsigned startOrder, unsigned cancelOrder, int priority, int schedPolicy=SCHED_RR) | |
~Thread () | |
bool | isRunning () |
bool | isPingable () |
void | raise (int sigNo) |
unsigned | startOrder () |
unsigned | cancelOrder () |
void | waitUntilReady () |
std::string | name () |
Static Public Member Functions | |
static | THREAD_CLEAN (unlockMutex) |
Public Attributes | |
bool | wasError_ |
Define a class to encapsulate thread handling.
gcp::util::Thread::Thread | ( | THREAD_START * | startFn, |
THREAD_CLEAN * | cleanFn, | ||
THREAD_PING * | pingFn, | ||
std::string | name, | ||
unsigned | startOrder = 0 , |
||
unsigned | cancelOrder = 0 |
||
) |
Constructor method.
startFn | A user-supplied startup function for this thread. Obviously, this cannot be NULL. |
cleanFn | A user-supplied startup function for this thread. Can be NULL, in which case the default cleanup handler is a no-op. |
pingFn | A user-supplied method of pinging this thread. Can be NULL, in which case isPingable() returns false and ping() is a no-op. |
name | A name to associate with this thread. |
startOrder | The order in which to start this thread |
stopOrder | The order in which to stop this thread |
schedPolicy | The Scheduling policy for this thread |
Thread::~Thread | ( | ) |
Destructor method
....................................................................... Thread destructor
void Thread::broadcastDone | ( | ) |
Let other threads know we are done
Exception | ....................................................................... Broadcast to any waiting threads that we are done |
void Thread::broadcastReady | ( | ) |
Let other threads know we are ready
Exception | ....................................................................... Broadcast to any waiting threads that we are ready |
void Thread::cancel | ( | ) |
bool Thread::isPingable | ( | ) |
Return true if a ping function has been installed.
....................................................................... Return true if a ping function has been installed for this thread.
bool Thread::isRunning | ( | ) |
Return true once this thread is running.
....................................................................... Return true if this thread is running
bool Thread::matchName | ( | std::string | compname | ) |
Return true if the passed argument matches the name of this thread.
....................................................................... Return true if the passed name matches
void Thread::ping | ( | void * | arg | ) |
void Thread::raise | ( | int | sigNo | ) |
Raise a signal to this thread.
....................................................................... Raise a signal to this thread.
void Thread::setRunState | ( | bool | state | ) |
void Thread::start | ( | void * | arg | ) |
Function by which a caller can start up this thread
***NB: this method blocks until the startup function (passed as void* arg) calls broadcastReady() below, to allow synchronization. You MUST make sure your thread startup function calls broadcastReady() or the thread calling run() will never unblock.
string Thread::strName | ( | ) |
Print the name of this thread
....................................................................... Return the name string of this thread
|
static |
A wrapper around pthread_mutex_unlock() suitable for passing to pthread_cleanup_push()
bool gcp::util::Thread::wasError_ |
A value to be returned if an error occurs on startup