Blue Brain BioExplorer
core::TaskFunctor Class Reference

#include <TaskFunctor.h>

Inheritance diagram for core::TaskFunctor:

Public Types

using ProgressFunc = std::function< void(std::string, float, float)>
 

Public Member Functions

void setProgressFunc (const ProgressFunc &progressFunc)
 
void progress (const std::string &message, const float increment, const float amount)
 
void setCancelToken (async::cancellation_token &cancelToken)
 
void cancelCheck () const
 

Detailed Description

A base class for functors that can be used for Tasks. It provides support for progress reporting and cancellation during execution.

Definition at line 41 of file TaskFunctor.h.

Member Typedef Documentation

◆ ProgressFunc

using core::TaskFunctor::ProgressFunc = std::function<void(std::string, float, float)>

message, increment, amount

Definition at line 45 of file TaskFunctor.h.

Member Function Documentation

◆ cancelCheck()

void core::TaskFunctor::cancelCheck ( ) const
inline

Checks if the execution has been cancelled. If so, this will throw an exception that is ultimately handled by the task and is stored in the tasks' result.

Definition at line 73 of file TaskFunctor.h.

◆ progress()

void core::TaskFunctor::progress ( const std::string &  message,
const float  increment,
const float  amount 
)
inline

Report progress using the provided callback from setProgressFunc() and also check if the execution has been cancelled.

Parameters
messagethe progress message
incrementthe fractional increment of this progress update
amountthe absolute amount of progress at the time of this update

Definition at line 58 of file TaskFunctor.h.

◆ setCancelToken()

void core::TaskFunctor::setCancelToken ( async::cancellation_token &  cancelToken)
inline

Set the cancel token from e.g. the task that uses this functor.

Definition at line 66 of file TaskFunctor.h.

◆ setProgressFunc()

void core::TaskFunctor::setProgressFunc ( const ProgressFunc progressFunc)
inline

Set the function when progress() is called.

Definition at line 48 of file TaskFunctor.h.


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