Tomographer  v5.2
Tomographer C++ Framework Documentation
Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ > Class Template Reference

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...
 

Detailed Description

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
class Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >

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.

Member Function Documentation

§ collectedTaskResult()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
const TaskResultType& Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::collectedTaskResult ( std::size_t  k) const
inline

Returns the result of the given task.

Definition at line 417 of file multiproc.h.

§ collectedTaskResults()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
const std::vector<TaskResultType*>& Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::collectedTaskResults ( ) const
inline

Returns the results of all the tasks.

Definition at line 410 of file multiproc.h.

§ numTaskRuns()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
TaskCountIntType Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::numTaskRuns ( ) const
inline

The total number of task instances that were run.

Definition at line 405 of file multiproc.h.

§ requestInterrupt()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
void Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::requestInterrupt ( )
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.

§ requestPeriodicStatusReport()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
template<typename IntType >
void Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::requestPeriodicStatusReport ( IntType  milliseconds)
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.

§ requestStatusReport()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
void Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::requestStatusReport ( )
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().

Note
This function is safe to be called from within a signal handler.

Definition at line 447 of file multiproc.h.

§ run()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
void Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::run ( )
inline

Run the tasks.

Definition at line 374 of file multiproc.h.

§ setStatusReportHandler()

template<typename TaskType_, typename TaskCData_, typename LoggerType_, typename TaskCountIntType_ = int>
template<typename Fn >
void Tomographer::MultiProc::Sequential::TaskDispatcher< TaskType_, TaskCData_, LoggerType_, TaskCountIntType_ >::setStatusReportHandler ( Fn  fnstatus)
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.


The documentation for this class was generated from the following file: