Blue Brain BioExplorer
core::Task< T > Class Template Reference

#include <Task.h>

Inheritance diagram for core::Task< T >:
Collaboration diagram for core::Task< T >:

Public Types

using Type = async::task< T >
 

Public Member Functions

 Task ()=default
 
template<typename F >
 Task (F &&functor)
 
void schedule () override
 
result ()
 
auto & get ()
 
- Public Member Functions inherited from core::AbstractTask
virtual ~AbstractTask ()=default
 
void cancel (std::function< void()> done={})
 
void finishCancel ()
 
bool canceled () const
 

Protected Member Functions

template<typename F >
auto && _setupFunctor (F &&functor)
 

Protected Attributes

Type _task
 
- Protected Attributes inherited from core::AbstractTask
async::cancellation_token _cancelToken
 
std::function< void()> _cancelDone
 
std::atomic_bool _cancelled {false}
 

Additional Inherited Members

- Public Attributes inherited from core::AbstractTask
Progress progress {"Scheduling task ..."}
 

Detailed Description

template<typename T>
class core::Task< T >

A task type which is directly scheduled after creation. Its result after successful execution is of type T.

If the functor is of type TaskFunctor, it will be provided with cancel support and progress feedback possibility.

Definition at line 95 of file Task.h.

Member Typedef Documentation

◆ Type

template<typename T >
using core::Task< T >::Type = async::task<T>

Definition at line 98 of file Task.h.

Constructor & Destructor Documentation

◆ Task() [1/2]

template<typename T >
core::Task< T >::Task ( )
default

Create an empty task; use task() and async++ to do something meaningful.

◆ Task() [2/2]

template<typename T >
template<typename F >
core::Task< T >::Task ( F &&  functor)
inline

Create and schedule a task with the given functor or lambda.

Definition at line 107 of file Task.h.

Member Function Documentation

◆ _setupFunctor()

template<typename T >
template<typename F >
auto&& core::Task< T >::_setupFunctor ( F &&  functor)
inlineprotected

Definition at line 129 of file Task.h.

◆ get()

template<typename T >
auto& core::Task< T >::get ( )
inline
Returns
access to the async++ task for chaining, assignment, etc.

Definition at line 123 of file Task.h.

◆ result()

template<typename T >
T core::Task< T >::result ( )
inline
Returns
the result of tasks, or an exception in case of errors or cancellation.

Definition at line 121 of file Task.h.

◆ schedule()

template<typename T >
void core::Task< T >::schedule ( )
inlineoverridevirtual

NOP for this task; tasks are running after construction.

Implements core::AbstractTask.

Reimplemented in core::DeferredTask< T >.

Definition at line 113 of file Task.h.

Member Data Documentation

◆ _task

template<typename T >
Type core::Task< T >::_task
protected

Definition at line 126 of file Task.h.


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