Back to Taskflow

tf::TFProfObserver class

docs/classtf_1_1TFProfObserver.html

4.0.03.6 KB
Original Source

tf::TFProfObserver class

class to create an observer based on the built-in taskflow profiler format

A tf::TFProfObserver inherits tf::ObserverInterface and defines methods to dump the observed thread activities into a format that can be visualized through Taskflow Profiler.

tf::Taskflow taskflow;tf::Executor executor;// insert tasks into taskflow// ...// create a custom observerstd::shared\_ptr\<tf::TFProfObserver\> observer = executor.make\_observer\<tf::TFProfObserver\>();// run the taskflowexecutor.run(taskflow).wait();// dump the thread activities to Taskflow Profiler format.observer-\>dump(std::cout);

Base classes

class ObserverInterfaceclass to derive an executor observer

Public functions

void dump(std::ostream& ostream) constdumps the timelines into a Taskflow Profiler format through an output streamauto dump() const -> std::stringdumps the timelines into a JSON stringvoid summary(std::ostream& ostream) constshows the summary report through an output streamauto summary() const -> std::stringreturns the summary report in a stringvoid clear()clears the timeline dataauto num_tasks() const -> size_tqueries the number of tasks observedauto num_workers() const -> size_tqueries the number of observed workers

Private functions

void set_up(size_t num_workers) finalconstructor-like method to call when the executor observer is fully createdvoid on_entry(WorkerView wv, TaskView task_view) finalmethod to call before a worker thread executes a closurevoid on_exit(WorkerView wv, TaskView task_view) finalmethod to call after a worker thread executed a closure

Function documentation

void tf::TFProfObserver::set_up(size_t num_workers) final private

constructor-like method to call when the executor observer is fully created

Parameters
num_workers

void tf::TFProfObserver::on_entry(WorkerView wv, TaskView task_view) final private

method to call before a worker thread executes a closure

Parameters
wv
task_view

void tf::TFProfObserver::on_exit(WorkerView wv, TaskView task_view) final private

method to call after a worker thread executed a closure

Parameters
wv
task_view