ResultsCollector takes care of collecting the results from each task run.
In the following, ConstantDataType is some type that was specified to the task dispatcher. The type CountType designates the type used to count tasks (usually an integral type of course). Also the type ResultType is the type declared for a result by the task (Task Interface). You may make the methods here take template parameters so you don't have to worry about the exact types of these parameters.
- void init(CountType num_total_runs, CountType n_chunk, const ConstantDataType * pcdata)
- init() will be called before the tasks are run (e.g. before starting the parallel section), and may be used to initialize data.
- collect_result(CountType task_no, const ResultType& taskresult, const ConstantDataType * pcdata)
- Called each time a task has finished, with the corresponding task result, along with information about which task it was and as always the shared constant data. This method does not need to worry about concurrence, for example writing to shared data (it is either called from the main thread in a critical section, or the data was serialized and passed to the main process, etc.)
- in the OMP task dispatcher (Tomographer::MultiProc::OMP::TaskDispatcher), this is called within a
critical
OMP section, so it may safely access and write shared data.
- void runs_finished(CountType num_total_runs, const ConstantDataType * pcdata)
- Called after all the tasks have finished. This is the good time to, e.g., finalize collected values, such as multiplying by parameter space volume, dividing by the number of samples to get the average, etc.