Equalizer
1.2.1
|
An utility class to execute code in a separate execution thread. More...
#include <thread.h>
Public Member Functions | |
COBASE_API | Thread () |
Construct a new thread. | |
COBASE_API | Thread (const Thread &from) |
Copy constructor. | |
virtual COBASE_API | ~Thread () |
Destruct the thread. | |
COBASE_API bool | start () |
Start the thread. | |
virtual bool | init () |
The init function for the child thread. | |
virtual void | run ()=0 |
The entry function for the child thread. | |
virtual COBASE_API void | exit () |
Exit the child thread immediately. | |
COBASE_API void | cancel () |
Cancel (stop) the child thread. | |
COBASE_API bool | join () |
Wait for the exit of the child thread. | |
bool | isStopped () const |
Return if the thread is stopped. | |
bool | isRunning () const |
Return if the thread is running. | |
COBASE_API bool | isCurrent () const |
Static Public Member Functions | |
static COBASE_API ThreadID | getSelfThreadID () |
static COBASE_API void | yield () |
static void | pinCurrentThread () |
static COBASE_API void | setName (const std::string &name) |
Friends | |
void | _notifyStopping (void *) |
std::ostream & | operator<< (std::ostream &os, const Thread *) |
Print the thread to the given output stream. |
An utility class to execute code in a separate execution thread.
COBASE_API co::base::Thread::Thread | ( | ) |
Construct a new thread.
COBASE_API co::base::Thread::Thread | ( | const Thread & | from | ) |
Copy constructor.
virtual COBASE_API co::base::Thread::~Thread | ( | ) | [virtual] |
Destruct the thread.
COBASE_API void co::base::Thread::cancel | ( | ) |
Cancel (stop) the child thread.
This function is not to be called from the child thread.
virtual COBASE_API void co::base::Thread::exit | ( | ) | [virtual] |
Exit the child thread immediately.
This function does not return. It is only to be called from the child thread.
static COBASE_API ThreadID co::base::Thread::getSelfThreadID | ( | ) | [static] |
virtual bool co::base::Thread::init | ( | ) | [inline, virtual] |
The init function for the child thread.
The parent thread will not be unlocked before this function has been executed. If the thread initialization fails, that is, this method does return false, the thread will be stopped and the start() method will return false.
Reimplemented in co::WorkerThread< Q >.
COBASE_API bool co::base::Thread::isCurrent | ( | ) | const |
bool co::base::Thread::isRunning | ( | ) | const [inline] |
bool co::base::Thread::isStopped | ( | ) | const [inline] |
COBASE_API bool co::base::Thread::join | ( | ) |
Wait for the exit of the child thread.
Referenced by eqAsync::Pipe::configExit().
virtual void co::base::Thread::run | ( | ) | [pure virtual] |
The entry function for the child thread.
This method should contain the main execution routine for the thread and is called after a successful init().
Implemented in eq::Node::TransmitThread, eqAsync::AsyncFetcher, and co::WorkerThread< Q >.
COBASE_API bool co::base::Thread::start | ( | ) |
std::ostream& operator<< | ( | std::ostream & | os, |
const Thread * | |||
) | [friend] |
Print the thread to the given output stream.