CVD::RunnableBatch Class Reference

#include <runnable_batch.h>

List of all members.

Classes

class  RunMessageInThread

Public Member Functions

void join ()
 RunnableBatch (unsigned int p)
void schedule (std::tr1::shared_ptr< Runnable > r)
 ~RunnableBatch ()

Private Attributes

bool joined
unsigned int parallelism
std::tr1::shared_ptr
< MessageQueue
< std::tr1::shared_ptr
< Runnable > > > 
queue
std::vector
< std::tr1::shared_ptr
< RunMessageInThread > > 
threads

Detailed Description

This class provides a simple job manager for tasks derived from CVD:Runnable. The class operates using a small pool of threads, so new tasks are run in existing free threads, not new ones. Overhead will only be due to locking in MessageQueue and shared_ptr.

Definition at line 14 of file runnable_batch.h.


Constructor & Destructor Documentation

CVD::RunnableBatch::RunnableBatch ( unsigned int  p  ) 

Construct a job manager pallelism Number of threads to use. Note that 1 thread will cause jobs to be executed in one new thread. 0 threads will cause the jobs to be executed in the current thread. This will prevent thread spawning and should make debugging easier. This is the behaviour if CVD is compiled without threading support.

CVD::RunnableBatch::~RunnableBatch (  ) 

Destruct the job manager. This will wait for all threads to finish and terminate.


Member Function Documentation

void CVD::RunnableBatch::join (  ) 

Wait until all pending tasks have been run, then terminate all threads.

void CVD::RunnableBatch::schedule ( std::tr1::shared_ptr< Runnable r  ) 

Put a task on the queue. This will be run at some point in the future. Job lifetime is managed by shared_ptr, so they may be managed wither by RunnableBatch or by the caller.


Member Data Documentation

Definition at line 17 of file runnable_batch.h.

unsigned int CVD::RunnableBatch::parallelism [private]

Definition at line 18 of file runnable_batch.h.

std::tr1::shared_ptr<MessageQueue<std::tr1::shared_ptr<Runnable> > > CVD::RunnableBatch::queue [private]

Definition at line 31 of file runnable_batch.h.

std::vector<std::tr1::shared_ptr<RunMessageInThread> > CVD::RunnableBatch::threads [private]

Definition at line 30 of file runnable_batch.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libcvd
Author(s): Edward Rosten, Paul Smith, Tom Drummond, Gerhard Reitmayr, Ethan Eade, Timothy Gan, Chris Kemp, Georg Klein
autogenerated on Fri Jan 11 09:13:52 2013