# tf::AsyncTask class
#include <taskflow/core/async_task.hpp>

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.

    // main thread retains shared ownership of async task A
    tf::AsyncTask A = executor.silent_dependent_async([](){});

    // task A remains alive (i.e., at least one ref count by the main thread)
    // when being added to the dependency list of async task B
    tf::AsyncTask B = 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.

## Constructors, destructors, conversion operators

AsyncTask() defaulted
  constructs an empty task handle
~AsyncTask()
  destroys the managed async task if this is the last owner
AsyncTask(const AsyncTask& rhs)
  constructs an async task that shares ownership of `rhs`
AsyncTask(AsyncTask&& rhs)
  move-constructs an async task from `rhs`

## Public functions

auto operator=(const AsyncTask& rhs) -> AsyncTask&
  copy-assigns the async task from `rhs`
auto operator=(AsyncTask&& rhs) -> AsyncTask&
  move-assigns the async task from `rhs`
auto empty() const -> bool
  checks if this async task is associated with a callable
void reset()
  release the managed object of `this`
auto hash_value() const -> size_t
  obtains the hashed value of this async task
auto use_count() const -> size_t
  returns the number of shared owners that are currently managing this async task
auto is_done() const -> bool
  checks if the async task finishes

## Function documentation

### AsyncTask& 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& 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`.

Tab / T to search, Esc to close
…

Search for symbols, directories, files, pages or modules. You can omit any prefix from the symbol or file path; adding a `:` or `/` suffix lists all members of given symbol or directory.

Use ↓ / ↑ to navigate through the list, Enter to go. Tab autocompletes common prefix, you can copy a link to the result using ⌘ L while ⌘ M produces a Markdown link.

Sorry, nothing was found.