OpenWalnut
1.4.0
|
A threaded functor base class for producer-consumer-style multithreaded computation. More...
#include <WThreadedJobs.h>
Public Types | |
typedef Input_T | InputType |
the input type | |
typedef Job_T | JobType |
the job type | |
Public Member Functions | |
WThreadedJobs (boost::shared_ptr< InputType const > input) | |
Constructor. | |
virtual | ~WThreadedJobs () |
Destructor. | |
void | operator() (std::size_t id, std::size_t numThreads, WBoolFlag const &shutdown) |
The threaded function operation. | |
virtual bool | getJob (JobType &job)=0 |
Abstract function for the job aquisition. | |
virtual void | compute (boost::shared_ptr< InputType const > input, JobType const &job)=0 |
Abstract function that performs the actual computation per job. | |
Protected Attributes | |
boost::shared_ptr< InputType const > | m_input |
the input |
A threaded functor base class for producer-consumer-style multithreaded computation.
A job generator function produces jobs that are then distributed to the threads in a first come first serve manner. The first template parameter is the type of the input data, for example a WDataSetScalar. The second template parameter is the type of object that represents the jobs.
Both the getJob() and the compute() functions need to be implemented.
Definition at line 50 of file WThreadedJobs.h.
typedef Input_T WThreadedJobs< Input_T, Job_T >::InputType |
the input type
Definition at line 54 of file WThreadedJobs.h.
typedef Job_T WThreadedJobs< Input_T, Job_T >::JobType |
the job type
Reimplemented in wtracking::WThreadedTrackingFunction.
Definition at line 57 of file WThreadedJobs.h.
WThreadedJobs< Input_T, Job_T >::WThreadedJobs | ( | boost::shared_ptr< InputType const > | input | ) |
Constructor.
input | The input. |
Definition at line 104 of file WThreadedJobs.h.
References WThreadedJobs< Input_T, Job_T >::m_input.
WThreadedJobs< Input_T, Job_T >::~WThreadedJobs | ( | ) | [virtual] |
Destructor.
Definition at line 114 of file WThreadedJobs.h.
virtual void WThreadedJobs< Input_T, Job_T >::compute | ( | boost::shared_ptr< InputType const > | input, |
JobType const & | job | ||
) | [pure virtual] |
Abstract function that performs the actual computation per job.
input | The input data. |
job | The current job. |
virtual bool WThreadedJobs< Input_T, Job_T >::getJob | ( | JobType & | job | ) | [pure virtual] |
Abstract function for the job aquisition.
job | The job (output). |
void WThreadedJobs< Input_T, Job_T >::operator() | ( | std::size_t | id, |
std::size_t | numThreads, | ||
WBoolFlag const & | shutdown | ||
) |
The threaded function operation.
Pulls jobs and executes the
id | The thread's ID. |
numThreads | How many threads are working on the jobs. |
shutdown | A shared flag indicating the thread should be stopped. |
Definition at line 119 of file WThreadedJobs.h.
boost::shared_ptr< InputType const > WThreadedJobs< Input_T, Job_T >::m_input [protected] |
the input
Definition at line 99 of file WThreadedJobs.h.
Referenced by WThreadedJobs< Input_T, Job_T >::WThreadedJobs().