Base class for client thread code. More...
#include "thread.h"
Public Member Functions | |
Thread (ThreadSystem *runtime, ThreadFlags flags) | |
virtual | ~Thread () |
bool | Start () |
void | Join () |
virtual void | Run ()=0 |
Base class for client thread code.
net_instaweb::ThreadSystem::Thread::Thread | ( | ThreadSystem * | runtime, | |
ThreadFlags | flags | |||
) |
Initializes the thread object for given runtime, but does not start it. (You need to call Start() for that)
If you pass in kJoinable for flags, you must explicitly call Join() to wait for thread to complete and release associated resources. That is not needed with kDetach, but you are still responsible for cleaning up the Thread object.
Any mutexes and condvars you use must be compatible with the passed in 'runtime'.
virtual net_instaweb::ThreadSystem::Thread::~Thread | ( | ) | [virtual] |
Note: it is safe to delete the Thread object from within Run as far as this baseclass is concerned.
void net_instaweb::ThreadSystem::Thread::Join | ( | ) |
Waits for the thread executing Run() to exit. This must be called on every thread created with kJoinable.
bool net_instaweb::ThreadSystem::Thread::Start | ( | ) |
Invokes Run() in a separate thread. Returns if successful or not. ### MessageHandler?