SPH
Public Member Functions | Static Public Member Functions | List of all members
Task Class Reference

Task to be executed by one of available threads. More...

#include <Pool.h>

Inheritance diagram for Task:
ITask ShareFromThis< Task > Polymorphic

Public Member Functions

 Task (const Function< void()> &callable)
 
 ~Task ()
 
virtual void wait () override
 Waits till the task and all the child tasks are completed. More...
 
virtual bool completed () const override
 Checks if the task already finished. More...
 
void setParent (SharedPtr< Task > parent)
 Assigns a task that spawned this task. More...
 
void setException (std::exception_ptr exception)
 Saves exception into the task. More...
 
bool isRoot () const
 Returns true if this is the top-most task. More...
 
SharedPtr< TaskgetParent () const
 
void runAndNotify ()
 
- Public Member Functions inherited from Polymorphic
virtual ~Polymorphic ()
 
- Public Member Functions inherited from ShareFromThis< Task >
void setWeakPtr (const WeakPtr< Task > &weakPtr)
 
SharedPtr< TasksharedFromThis () const
 
WeakPtr< TaskweakFromThis () const
 

Static Public Member Functions

static SharedPtr< TaskgetCurrent ()
 Returns the currently execute task, or nullptr if no task is currently executed on this thread. More...
 

Additional Inherited Members

- Public Types inherited from ShareFromThis< Task >
using SHARE_FROM_THIS_TAG = void
 

Detailed Description

Task to be executed by one of available threads.

Definition at line 20 of file Pool.h.

Constructor & Destructor Documentation

◆ Task()

Task::Task ( const Function< void()> &  callable)
explicit

Definition at line 21 of file Pool.cpp.

◆ ~Task()

Task::~Task ( )

Definition at line 24 of file Pool.cpp.

Member Function Documentation

◆ completed()

bool Task::completed ( ) const
overridevirtual

Checks if the task already finished.

Implements ITask.

Definition at line 48 of file Pool.cpp.

◆ getCurrent()

SharedPtr< Task > Task::getCurrent ( )
static

Returns the currently execute task, or nullptr if no task is currently executed on this thread.

Definition at line 60 of file Pool.cpp.

◆ getParent()

SharedPtr< Task > Task::getParent ( ) const

Definition at line 56 of file Pool.cpp.

◆ isRoot()

bool Task::isRoot ( ) const

Returns true if this is the top-most task.

Definition at line 52 of file Pool.cpp.

◆ runAndNotify()

void Task::runAndNotify ( )

Definition at line 83 of file Pool.cpp.

◆ setException()

void Task::setException ( std::exception_ptr  exception)

Saves exception into the task.

The exception propagates into the top-most task.

Definition at line 75 of file Pool.cpp.

◆ setParent()

void Task::setParent ( SharedPtr< Task parent)

Assigns a task that spawned this task.

Can be nullptr if this is the root task.

Definition at line 64 of file Pool.cpp.

◆ wait()

void Task::wait ( )
overridevirtual

Waits till the task and all the child tasks are completed.

Implements ITask.

Definition at line 28 of file Pool.cpp.


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