class to derive an executor observer
The tf::ObserverInterface class let users define custom methods to monitor the behaviors of an executor. This is particularly useful when you want to inspect the performance of an executor and visualize when each thread participates in the execution of a task. To prevent users from direct access to the internal threads and tasks, tf::ObserverInterface provides immutable wrappers, tf::WorkerView and tf::TaskView, over workers and tasks.
Please refer to tf::WorkerView and tf::TaskView for details.
Example usage:
std::cout <<
"constructing observer " << name <<
'\n';
}
void set_up(size_t num_workers) override final {
std::cout <<
"setting up observer with " << num_workers <<
" workers\n";
}
void on_entry(WorkerView w,
tf::TaskView tv)
override final {
oss << "worker " << w.id() << " ready to run " << tv.name() << '\n';
}
void on_exit(WorkerView w,
tf::TaskView tv)
override final {
oss << "worker " << w.id() << " finished running " << tv.name() << '\n';
}
};
executor.
run(taskflow).wait();
class to create an executor for running a taskflow graph
Definition executor.hpp:50
tf::Future< void > run(Taskflow &taskflow)
runs a taskflow once
Definition executor.hpp:1573
std::shared_ptr< Observer > make_observer(ArgsT &&... args)
constructs an observer to inspect the activities of worker threads
Definition executor.hpp:1038
class to derive an executor observer
Definition observer.hpp:169
class to access task information from the observer interface
Definition task.hpp:638
class to create a taskflow object
Definition core/taskflow.hpp:73