OpenWalnut
1.5.0dev
|
A threaded functor base class for producer-consumer-style multithreaded computation. More...
#include <WThreadedJobs.h>
Public Types | |
typedef Input_T | InputType |
the input type More... | |
typedef Job_T | JobType |
the job type More... | |
Public Member Functions | |
WThreadedJobs (std::shared_ptr< InputType const > input) | |
Constructor. More... | |
virtual | ~WThreadedJobs () |
Destructor. More... | |
void | operator() (std::size_t id, std::size_t numThreads, WBoolFlag const &shutdown) |
The threaded function operation. More... | |
virtual bool | getJob (JobType &job)=0 |
Abstract function for the job aquisition. More... | |
virtual void | compute (std::shared_ptr< InputType const > input, JobType const &job)=0 |
Abstract function that performs the actual computation per job. More... | |
Protected Attributes | |
std::shared_ptr< InputType const > | m_input |
the input More... | |
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
Definition at line 57 of file WThreadedJobs.h.
WThreadedJobs< Input_T, Job_T >::WThreadedJobs | ( | std::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.
|
virtual |
Destructor.
Definition at line 114 of file WThreadedJobs.h.
|
pure virtual |
Abstract function that performs the actual computation per job.
input | The input data. |
job | The current 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.
|
protected |
the input
Definition at line 99 of file WThreadedJobs.h.
Referenced by WThreadedJobs< Input_T, Job_T >::WThreadedJobs().