#include <taskflow/core/taskflow.hpp>
template<typename T>
Future class
class to access the result of an execution
tf::
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
Public functions
Function documentation
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 |
---|
When you request a cancellation, the executor will stop scheduling any tasks onwards. Tasks that are already running will continue to finish (non-preemptive). You can call tf::Future::wait to wait for the cancellation to complete.