Page Speed Optimization Libraries
1.4.26.1
|
Base class for client thread code. More...
#include "thread.h"
Public Member Functions | |
Thread (ThreadSystem *runtime, StringPiece name, ThreadFlags flags) | |
virtual | ~Thread () |
bool | Start () |
Invokes Run() in a separate thread. Returns if successful or not. | |
void | Join () |
GoogleString | name () const |
virtual void | Run ()=0 |
Base class for client thread code.
net_instaweb::ThreadSystem::Thread::Thread | ( | ThreadSystem * | runtime, |
StringPiece | name, | ||
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'.
The 'name' will be used purely for debugging purposes. Note that on many systems (e.g. Linux PThreads) the OS will only keep track of 15 characters, so you may not want to get too wordy.
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.
Waits for the thread executing Run() to exit. This must be called on every thread created with kJoinable.