tf::AsyncTask
taskflow/core/async_task.hpp
class friend class Executor Executor tf::AsyncTask::Executor Executor
Node * Node* tf::AsyncTask::_node _node tf::AsyncTask::_node {nullptr}
tf::AsyncTask::AsyncTask
()=default
AsyncTask
tf::AsyncTask::AsyncTask

constructs an empty task handle

tf::AsyncTask::~AsyncTask
()
~AsyncTask
tf::AsyncTask::~AsyncTask

destroys the managed async task if this is the last owner

tf::AsyncTask::AsyncTask
(const AsyncTask &rhs)
AsyncTask
tf::AsyncTask::AsyncTask
const AsyncTask & rhs

constructs an async task that shares ownership of `rhs`

tf::AsyncTask::AsyncTask
(AsyncTask &&rhs)
AsyncTask
tf::AsyncTask::AsyncTask
AsyncTask && rhs

move-constructs an async task from `rhs`

AsyncTask & AsyncTask & tf::AsyncTask::operator= (const AsyncTask &rhs) operator= tf::AsyncTask::operator= const AsyncTask & rhs

copy-assigns the async task from `rhs`

Releases the managed object of `this` and retains a new shared ownership of `rhs`.

AsyncTask & AsyncTask & tf::AsyncTask::operator= (AsyncTask &&rhs) operator= tf::AsyncTask::operator= AsyncTask && rhs

move-assigns the async task from `rhs`

Releases the managed object of `this` and takes over the ownership of `rhs`.

bool bool tf::AsyncTask::empty () const empty tf::AsyncTask::empty

checks if this async task is associated with a callable

void void tf::AsyncTask::reset () reset tf::AsyncTask::reset

release the managed object of `this`

size_t size_t tf::AsyncTask::hash_value () const hash_value tf::AsyncTask::hash_value

obtains the hashed value of this async task

size_t size_t tf::AsyncTask::use_count () const use_count tf::AsyncTask::use_count

returns the number of shared owners that are currently managing this async task

bool bool tf::AsyncTask::is_done () const is_done tf::AsyncTask::is_done

checks if the async task finishes

tf::AsyncTask::AsyncTask
(Node *)
AsyncTask
tf::AsyncTask::AsyncTask
Node * ptr
void void tf::AsyncTask::_incref () _incref tf::AsyncTask::_incref
void void tf::AsyncTask::_decref () _decref tf::AsyncTask::_decref

class to create a dependent asynchronous task (async task)

A tf::AsyncTask is a lightweight handle that retains shared ownership of a dependent asynchronous task (async task) created by an executor. This shared ownership ensures that the async task remains alive when adding it to the dependency list of another async task, thus avoiding the classical ABA problem.

    //mainthreadretainssharedownershipofasynctaskA
    tf::AsyncTaskA=executor.silent_dependent_async([](){});

    //taskAremainsalive(i.e.,atleastonerefcountbythemainthread)
    //whenbeingaddedtothedependencylistofasynctaskB
    tf::AsyncTaskB=executor.silent_dependent_async([](){},A);

Currently, tf::AsyncTask is implemented based on the logic of C++ smart pointer std::shared_ptr and is considered cheap to copy or move as long as only a handful of objects own it. When a worker completes an async task, it will remove the task from the executor, decrementing the number of shared owners by one. If that counter reaches zero, the task is destroyed.

- tf::AsyncTask
  _decref
- tf::AsyncTask
  _incref
- tf::AsyncTask
  _node
- tf::AsyncTask
  AsyncTask
- tf::AsyncTask
  AsyncTask
- tf::AsyncTask
  AsyncTask
- tf::AsyncTask
  AsyncTask
- tf::AsyncTask
  empty
- tf::AsyncTask
  Executor
- tf::AsyncTask
  hash_value
- tf::AsyncTask
  is_done
- tf::AsyncTask
  operator=
- tf::AsyncTask
  operator=
- tf::AsyncTask
  reset
- tf::AsyncTask
  use_count
- tf::AsyncTask
  ~AsyncTask