template<typename T>
tf::Future class

class to access the result of task execution

tf::Future is a derived class from std::future that will eventually hold the execution result of a submitted taskflow (e.g., tf::Executor::run) or an asynchronous task (e.g., tf::Executor::async). In addition to base methods of std::future, you can call tf::Future::cancel to cancel the execution of the running taskflow associated with this future object. The following example cancels a submission of a taskflow that contains 1000 tasks each running one second.

tf::Executor executor;
tf::Taskflow taskflow;

for(int i=0; i<1000; i++) {
  taskflow.emplace([](){ 
    std::this_thread::sleep_for(std::chrono::seconds(1));
  });
}

// submit the taskflow
tf::Future fu = executor.run(taskflow);

// request to cancel the submitted execution above
fu.cancel();

// wait until the cancellation finishes
fu.get();

Constructors, destructors, conversion operators

Future() defaulted
default constructor
Future(const Future&) deleted
disabled copy constructor
Future(Future&&) defaulted
default move constructor

Public functions

auto operator=(const Future&) -> Future& deleted
disabled copy assignment
auto operator=(Future&&) -> Future& defaulted
default move assignment
auto cancel() -> bool
cancels the execution of the running taskflow associated with this future object

Function documentation

template<typename T>
tf::Future<T>::Future() defaulted

default constructor

template<typename T>
tf::Future<T>::Future(const Future&) deleted

disabled copy constructor

template<typename T>
tf::Future<T>::Future(Future&&) defaulted

default move constructor

template<typename T>
Future& tf::Future<T>::operator=(const Future&) deleted

disabled copy assignment

template<typename T>
Future& tf::Future<T>::operator=(Future&&) defaulted

default move assignment

template<typename T>
bool tf::Future<T>::cancel()

cancels the execution of the running taskflow associated with this future object

Returns true if the execution can be cancelled or false if the execution has already completed