Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
net_instaweb::ThreadSystem::Thread Class Referenceabstract

Base class for client thread code. More...

#include "thread.h"

Inheritance diagram for net_instaweb::ThreadSystem::Thread:
net_instaweb::CacheSpammer net_instaweb::LockManagerSpammer net_instaweb::SchedulerThread net_instaweb::TcpServerThreadForTesting

Public Member Functions

 Thread (ThreadSystem *runtime, StringPiece name, ThreadFlags flags)
 
virtual ~Thread ()
 
bool Start ()
 
bool Started () const
 
void Join ()
 
GoogleString name () const
 
virtual void Run ()=0
 

Detailed Description

Base class for client thread code.

Constructor & Destructor Documentation

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.

Member Function Documentation

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. Threads are not re-startable, you should create new instance of Thread if you want to create another thread.

bool net_instaweb::ThreadSystem::Thread::Started ( ) const
inline

Whether Start() ran successfully on this object, useful if your Thread may want to call Join() in it's destructor.


The documentation for this class was generated from the following file: