Blue Brain BioExplorer
core::AbstractTask Class Referenceabstract

#include <Task.h>

Inheritance diagram for core::AbstractTask:
Collaboration diagram for core::AbstractTask:

Public Member Functions

virtual ~AbstractTask ()=default
 
void cancel (std::function< void()> done={})
 
void finishCancel ()
 
bool canceled () const
 
virtual void schedule ()=0
 

Public Attributes

Progress progress {"Scheduling task ..."}
 

Protected Attributes

async::cancellation_token _cancelToken
 
std::function< void()> _cancelDone
 
std::atomic_bool _cancelled {false}
 

Detailed Description

A task is an operation that can be scheduled (directly, async, ...) and has support for progress reporting during the execution and cancellation of the execution.

Definition at line 35 of file Task.h.

Constructor & Destructor Documentation

◆ ~AbstractTask()

virtual core::AbstractTask::~AbstractTask ( )
virtualdefault

Member Function Documentation

◆ cancel()

void core::AbstractTask::cancel ( std::function< void()>  done = {})
inline

Cancels the task if is either waiting to be scheduled or already running. Will have no effect if the task already finished.

Parameters
donefor asynchronous cancel processing, this function will be remembered and can be called via finishCancel()

Definition at line 47 of file Task.h.

◆ canceled()

bool core::AbstractTask::canceled ( ) const
inline
Returns
true if the task has been cancelled.

Definition at line 68 of file Task.h.

◆ finishCancel()

void core::AbstractTask::finishCancel ( )
inline

Indicate that cancel processing has finished and call the function given to cancel().

Definition at line 61 of file Task.h.

◆ schedule()

virtual void core::AbstractTask::schedule ( )
pure virtual

Schedule the execution of the task. Depending on the concrete task type, the task could still be running though after construction.

Implemented in core::Task< T >, core::Task< ModelDescriptorPtr >, and core::DeferredTask< T >.

Member Data Documentation

◆ _cancelDone

std::function<void()> core::AbstractTask::_cancelDone
protected

Definition at line 80 of file Task.h.

◆ _cancelled

std::atomic_bool core::AbstractTask::_cancelled {false}
protected

Definition at line 81 of file Task.h.

◆ _cancelToken

async::cancellation_token core::AbstractTask::_cancelToken
protected

Definition at line 79 of file Task.h.

◆ progress

Progress core::AbstractTask::progress {"Scheduling task ..."}
Returns
access to the progress of task.

Definition at line 76 of file Task.h.


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