task_scheduler_observer Members

The following table provides additional information on the members of this template class.
Member Description
task_scheduler_observer()

Constructs instance with observing disabled.

~task_scheduler_observer()

Disables observing. Waits for extant invocations of on_scheduler_entry or on_scheduler_exit to complete.

void observe( bool state=true )

Enables observing if state is true; disables observing if state is false.

bool is_observing() const

Returns: True if observing is enabled; false otherwise.

virtual void on_scheduler_entry( bool is_worker)

The task scheduler invokes this method once per each thread participating in TBB work after enabling the observation and before it starts participating for the first time, or before it executes the first task stolen after enabling the observation.

The flag is_worker is true if the thread was created by the task scheduler; false otherwise.

Note

If a thread enables observing before spawning a task, it is guaranteed that the thread that executes the task will have invoked on_scheduler_entry before executing the task.

Effects: The default behavior does nothing.

virtual void on_scheduler_exit( bool is_worker )

The task scheduler invokes this method when a thread stops participating in task scheduling, if observing is enabled.

Caution

Sometimes on_scheduler_exit is invoked for a thread but not on_scheduler_entry. This situation can arise if a thread never steals a task.

Caution

A process does not wait for the worker threads to clean up. Thus a process can terminate before on_scheduler_exit is invoked.

Effects: The default behavior does nothing.