Nektar++
|
Base class for tasks to be sent to the ThreadManager to run. More...
#include <Thread.h>
Public Member Functions | |
ThreadJob () | |
Base constructor. More... | |
virtual | ~ThreadJob () |
Base destructor. More... | |
virtual void | Run ()=0 |
void | SetWorkerNum (unsigned int num) |
Set number of worker threads. More... | |
Protected Member Functions | |
unsigned int | GetWorkerNum () |
Private Attributes | |
unsigned int | m_workerNum |
Base class for tasks to be sent to the ThreadManager to run.
For a parallel region the overall task should be divided into tasklets, each capable of running independently of other tasklets, in any order. Each of these tasklets should be represented by an instance of a subclass of ThreadJob.
Exactly how to partition the overall task will be problem dependent, but the ideal case is to have as many tasklets as there are worker threads (available through ThreadManager::GetNumWorkers() ) and for each tasklet to take the same amount of computational effort. Clearly, the tasklets should not overwrite one another's data, and data locations they are writing to should be sufficiently far apart to avoid cache ping pong.
Subclasses may define as many variables and functions as are necessary. Instance of the subclass will be destructed once the ThreadManager has finished the Run() method.
Nektar::Thread::ThreadJob::ThreadJob | ( | ) |
|
virtual |
|
protected |
Returns an integer identifying the worker thread the job is running on. Value will be 0...N, where N is the number of active worker threads.
Definition at line 90 of file Thread.cpp.
References m_workerNum.
|
pure virtual |
This method will be called when the task is loaded onto a worker thread and is ready to run. When Run has finished this instance will be destructed.
Referenced by Nektar::Thread::ThreadWorkerBoost::RunJobs().
void Nektar::Thread::ThreadJob::SetWorkerNum | ( | unsigned int | num | ) |
Set number of worker threads.
Part of the thread interface. Do not use unless you're an implementation of ThreadManager.
Definition at line 81 of file Thread.cpp.
References m_workerNum.
Referenced by Nektar::Thread::ThreadWorkerBoost::RunJobs().
|
private |
Definition at line 126 of file Thread.h.
Referenced by GetWorkerNum(), and SetWorkerNum().