tf::ChromeObserver class

class to create an observer based on Chrome tracing format

A tf::ChromeObserver inherits tf::ObserverInterface and defines methods to dump the observed thread activities into a format that can be visualized through Chrome Tracing.

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

// insert tasks into taskflow
// ...
  
// create a custom observer
std::shared_ptr<tf::ChromeObserver> observer = executor.make_observer<tf::ChromeObserver>();

// run the taskflow
executor.run(taskflow).wait();

// dump the thread activities to a chrome-tracing format.
observer->dump(std::cout);

Base classes

class ObserverInterface
class to derive an executor observer

Public functions

void dump(std::ostream& ostream) const
dumps the timelines into a Chrome Tracing format through an output stream
auto dump() const -> std::string
dumps the timelines into a Chrome Tracing format
void clear()
clears the timeline data
auto num_tasks() const -> size_t
queries the number of tasks observed

Private functions

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

Function documentation

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

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

Parameters
num_workers the number of the worker threads in the executor

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

method to call before a worker thread executes a closure

Parameters
wv an immutable view of this worker thread
task_view a constant wrapper object to the task

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

method to call after a worker thread executed a closure

Parameters
wv an immutable view of this worker thread
task_view a constant wrapper object to the task