Tomographer
v5.2
Tomographer C++ Framework Documentation
|
Executes multiple tasks sequentially. More...
#include <tomographer/multiproc.h>
Public Types | |
typedef TaskType_ | TaskType |
typedef TaskType::StatusReportType | TaskStatusReportType |
typedef TaskCData_ | TaskCData |
typedef LoggerType_ | LoggerType |
typedef TaskCountIntType_ | TaskCountIntType |
typedef TaskType::ResultType | TaskResultType |
typedef FullStatusReport< TaskStatusReportType, TaskCountIntType > | FullStatusReportType |
typedef std::function< void(const FullStatusReportType &)> | FullStatusReportCallbackType |
Public Member Functions | |
TaskDispatcher (TaskCData *pcdata_, LoggerType &logger_, TaskCountIntType num_total_runs_) | |
void | run () |
Run the tasks. More... | |
TaskCountIntType | numTaskRuns () const |
The total number of task instances that were run. More... | |
const std::vector< TaskResultType * > & | collectedTaskResults () const |
Returns the results of all the tasks. More... | |
const TaskResultType & | collectedTaskResult (std::size_t k) const |
Returns the result of the given task. More... | |
template<typename Fn > | |
void | setStatusReportHandler (Fn fnstatus) |
assign a callable to be called whenever a status report is requested More... | |
void | requestStatusReport () |
Request a status report. More... | |
template<typename IntType > | |
void | requestPeriodicStatusReport (IntType milliseconds) |
Request a status report periodically. More... | |
void | requestInterrupt () |
Interrupt all tasks as soon as possible. More... | |
Executes multiple tasks sequentially.
This task dispatcher is useful mainly for test cases, when testing tasks (and to see if a set of classes adhere well to the task dispatcher type interfaces, see Multiprocessing Task Interfaces).
Task must be a Task Interface compliant type
TaskCData should conform to the TaskCData Interface.
LoggerType is the type used for logging messages (derived from Logger::LoggerBase)
TaskCountIntType should be a type to use to count the number of tasks. Usually there's no reason not to use an int
, unless you want to launch an exceptionally large number of tasks
Definition at line 230 of file multiproc.h.
|
inline |
Returns the result of the given task.
Definition at line 417 of file multiproc.h.
|
inline |
Returns the results of all the tasks.
Definition at line 410 of file multiproc.h.
|
inline |
The total number of task instances that were run.
Definition at line 405 of file multiproc.h.
|
inline |
Interrupt all tasks as soon as possible.
As soon as the tasks notice this request, they will quit. Any computation performed until then is undefined, and the run() function throws a TasksInterruptedException.
Definition at line 471 of file multiproc.h.
|
inline |
Request a status report periodically.
After this function is called, a status report will be automatically deliviered every milliseconds milliseconds to the handler set by setStatusReportHandler().
Pass -1 to cancel the periodic status reporting.
Definition at line 460 of file multiproc.h.
|
inline |
Request a status report.
This function makes a note that a status report has been requested. Subsequently, the currently running task should notice it (provided it regularly queries for status report requests as described on the page Task Interface), and provides a status report. This status report, along with some additional information such as overall progress in number of task forms the full status report which is passed on to the callback set with setStatusReportHandler().
Definition at line 447 of file multiproc.h.
|
inline |
Run the tasks.
Definition at line 374 of file multiproc.h.
|
inline |
assign a callable to be called whenever a status report is requested
This function remembers the given fnstatus callable, so that each time that requestStatusReport() is called at any later point, then this callback will be invoked.
The callback, when invoked, will be called with a single parameter of type FullStatusReport<TaskStatusReportType>.
Definition at line 431 of file multiproc.h.