Base class for threads that can be kept in a Dv::Thread::Pool. More...
#include <pool.h>
Classes | |
struct | Init |
Auxiliary class which is used to support thread specific initialization and finalization. More... | |
Public Member Functions | |
Thread (Pool &pool) | |
Constructor. | |
virtual | ~Thread () |
Destructor. | |
virtual void | work ()=0 |
Do some work. | |
virtual void | setup_for_work ()=0 |
Set up this thread for work. | |
int | main () |
Main function of the thread. | |
Protected Member Functions | |
virtual Init::shared_ptr | init () const |
Function that creates a shared pointer to a (class derived from) Init object. | |
Private Types | |
enum | { WORK = 0 } |
Private Member Functions | |
void | setup () |
Set up this thread with input for work. | |
bool | wait () |
Wait for the WORK condition to be signaled. | |
void | signal () |
Signal the WORK condition. | |
Private Attributes | |
Monitor | monitor_ |
Pool & | pool_ |
Friends | |
class | Pool |
class | Init |
Base class for threads that can be kept in a Dv::Thread::Pool.
Dv::Thread::Pool::Thread::Thread | ( | Pool & | pool | ) |
Constructor.
pool | to which the thread belongs |
virtual Dv::Thread::Pool::Thread::~Thread | ( | ) | [virtual] |
Destructor.
Reimplemented from Dv::Thread::Thread.
virtual void Dv::Thread::Pool::Thread::work | ( | ) | [pure virtual] |
Do some work.
This function is called by Dv::Thread::Pool::Thread::main whenever the thread is selected by Dv::Thread::Pool::delegate.
virtual void Dv::Thread::Pool::Thread::setup_for_work | ( | ) | [pure virtual] |
Set up this thread for work.
Typically, this would fill in some input data, e.g. by grabbing them from the Thread factory (see test-pool.C in the distribution for an example).
int Dv::Thread::Pool::Thread::main | ( | ) | [virtual] |
Main function of the thread.
Reimplemented from Dv::Thread::Thread.
virtual Init::shared_ptr Dv::Thread::Pool::Thread::init | ( | ) | const [inline, protected, virtual] |
Function that creates a shared pointer to a (class derived from) Init object.
void Dv::Thread::Pool::Thread::setup | ( | ) | [private] |
Set up this thread with input for work.
This function grabs the monitor and calls Dv::Pool::Thread::setup_for_work
bool Dv::Thread::Pool::Thread::wait | ( | ) | [inline, private] |
Wait for the WORK condition to be signaled.
Reimplemented from Dv::Thread::Thread.
References monitor_, Dv::Thread::Monitor::wait(), and WORK.
void Dv::Thread::Pool::Thread::signal | ( | ) | [inline, private] |
Signal the WORK condition.
This function should not be called by the Thread itself.
References monitor_, Dv::Thread::Monitor::signal(), and WORK.
friend class Pool [friend] |
friend class Init [friend] |
Monitor Dv::Thread::Pool::Thread::monitor_ [private] |
Pool& Dv::Thread::Pool::Thread::pool_ [private] |
dvthread-0.13.4 | [11 December, 2009] |