tf::TFProfObserver class | Taskflow QuickStart

# 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 observer
    std::shared_ptr<tf::TFProfObserver> observer = executor.make_observer<tf::TFProfObserver>();

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

    // dump the thread activities to Taskflow Profiler 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 Taskflow Profiler format through an output stream
auto dump() const -> std::string
  dumps the timelines into a JSON string
void summary(std::ostream& ostream) const
  shows the summary report through an output stream
auto summary() const -> std::string
  returns the summary report in a string
void clear()
  clears the timeline data
auto num_tasks() const -> size_t
  queries the number of tasks observed
auto num_workers() const -> size_t
  queries the number of observed workers

## 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::TFProfObserver::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::TFProfObserver::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::TFProfObserver::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

Tab / T to search, Esc to close
…

Search for symbols, directories, files, pages or modules. You can omit any prefix from the symbol or file path; adding a `:` or `/` suffix lists all members of given symbol or directory.

Use ↓ / ↑ to navigate through the list, Enter to go. Tab autocompletes common prefix, you can copy a link to the result using ⌘ L while ⌘ M produces a Markdown link.

Sorry, nothing was found.