tbb::interface6::task_scheduler_observer Class Reference

`#include <task_scheduler_observer.h>`

Inheritance diagram for tbb::interface6::task_scheduler_observer:
Collaboration diagram for tbb::interface6::task_scheduler_observer:

## Public Member Functions

| task_scheduler_observer (bool local=false)
| Construct local or global observer in inactive state (observation disabled). More...
| task_scheduler_observer (task_arena &a)
| Construct local observer for a given arena in inactive state (observation disabled). More...
virtual | ~task_scheduler_observer ()
void | observe (bool state=true)
| Enable or disable observation. More...
Public Member Functions inherited from tbb::internal::task_scheduler_observer_v3
void __TBB_EXPORTED_METHOD | observe (bool state=true)
| Enable or disable observation. More...
bool | is_observing () const
| Returns true if observation is enabled, false otherwise. More...
| task_scheduler_observer_v3 ()
| Construct observer with observation disabled. More...
virtual void | on_scheduler_entry (bool)
| Entry notification. More...
virtual void | on_scheduler_exit (bool)
| Exit notification. More...
virtual | ~task_scheduler_observer_v3 ()
| Destructor automatically switches observation off if it is enabled. More...

## Private Types

enum | { global_tag = 0 , implicit_tag = 1 }

## Private Attributes

intptr_t | my_context_tag
| contains task_arena pointer or tag indicating local or global semantics of the observer More...

## Static Private Attributes

static const intptr_t | v6_trait = (intptr_t)((~(uintptr_t)0 >> 1) + 1)

## Friends

class | internal::task_scheduler_observer_v3
class | internal::observer_proxy
class | internal::observer_list

## Detailed Description

Definition at line 92 of file task_scheduler_observer.h.

## Member Enumeration Documentation

## anonymous enum

anonymous enum

private

Enumerator
global_tag |
implicit_tag |

Definition at line 104 of file task_scheduler_observer.h.

{ global_tag = 0, implicit_tag = 1 };
tbb::interface6::task_scheduler_observer::global_tag
@ global_tag
Definition: task_scheduler_observer.h:104
tbb::interface6::task_scheduler_observer::implicit_tag
@ implicit_tag
Definition: task_scheduler_observer.h:104

## Constructor & Destructor Documentation

## task_scheduler_observer() [1/2]

tbb::interface6::task_scheduler_observer::task_scheduler_observer | ( | bool | local = `false` | ) |

inline explicit

Construct local or global observer in inactive state (observation disabled).

For a local observer entry/exit notifications are invoked whenever a worker thread joins/leaves the arena of the observer's owner thread. If a thread is already in the arena when the observer is activated, the entry notification is called before it executes the first stolen task. TODO: Obsolete. Global observer semantics is obsolete as it violates master thread isolation guarantees and is not composable. Thus the current default behavior of the constructor is obsolete too and will be changed in one of the future versions of the library.

Definition at line 117 of file task_scheduler_observer.h.

{
#if __TBB_ARENA_OBSERVER
my_context_tag = local? implicit_tag : global_tag;
#else
__TBB_ASSERT_EX( !local, NULL );
my_context_tag = global_tag;
#endif
}
__TBB_ASSERT_EX
#define __TBB_ASSERT_EX(predicate, comment)
"Extended" version is useful to suppress warnings if a variable is only used with an assert
Definition: tbb_stddef.h:167
tbb::interface6::task_scheduler_observer::my_context_tag
intptr_t my_context_tag
contains task_arena pointer or tag indicating local or global semantics of the observer
Definition: task_scheduler_observer.h:103

References __TBB_ASSERT_EX, global_tag, implicit_tag, and my_context_tag.

## task_scheduler_observer() [2/2]

tbb::interface6::task_scheduler_observer::task_scheduler_observer | ( | task_arena & | a | ) |

inline explicit

Construct local observer for a given arena in inactive state (observation disabled).

entry/exit notifications are invoked whenever a thread joins/leaves arena. If a thread is already in the arena when the observer is activated, the entry notification is called before it executes the first stolen task.

Definition at line 131 of file task_scheduler_observer.h.

{
my_context_tag = (intptr_t)&a;
}

References my_context_tag.

## ~task_scheduler_observer()

virtual tbb::interface6::task_scheduler_observer::~task_scheduler_observer | ( |  | ) |

inline virtual

Destructor protects instance of the observer from concurrent notification. It is recommended to disable observation before destructor of a derived class starts, otherwise it can lead to concurrent notification callback on partly destroyed object

Definition at line 139 of file task_scheduler_observer.h.

{ if(my_proxy) observe(false); }
tbb::internal::task_scheduler_observer_v3::my_proxy
observer_proxy * my_proxy
Pointer to the proxy holding this observer.
Definition: task_scheduler_observer.h:46
tbb::interface6::task_scheduler_observer::observe
void observe(bool state=true)
Enable or disable observation.
Definition: task_scheduler_observer.h:144

References tbb::internal::task_scheduler_observer_v3::my_proxy, and observe().

Here is the call graph for this function:

## Member Function Documentation

## observe()

void tbb::interface6::task_scheduler_observer::observe | ( | bool | state = `true` | ) |

inline

Enable or disable observation.

Warning: concurrent invocations of this method are not safe. Repeated calls with the same state are no-ops.

Definition at line 144 of file task_scheduler_observer.h.

{
if( state && !my_proxy ) {
__TBB_ASSERT( !my_busy_count, "Inconsistent state of task_scheduler_observer instance");
my_busy_count.store<relaxed>(v6_trait);
}
internal::task_scheduler_observer_v3::observe(state);
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::relaxed
@ relaxed
No ordering.
Definition: atomic.h:61
tbb::internal::task_scheduler_observer_v3::observe
void __TBB_EXPORTED_METHOD observe(bool state=true)
Enable or disable observation.
tbb::internal::task_scheduler_observer_v3::my_busy_count
atomic< intptr_t > my_busy_count
Counter preventing the observer from being destroyed while in use by the scheduler.
Definition: task_scheduler_observer.h:50
tbb::interface6::task_scheduler_observer::v6_trait
static const intptr_t v6_trait
Definition: task_scheduler_observer.h:100

References __TBB_ASSERT, tbb::internal::task_scheduler_observer_v3::my_busy_count, tbb::internal::task_scheduler_observer_v3::my_proxy, tbb::internal::task_scheduler_observer_v3::observe(), tbb::relaxed, and v6_trait.

Referenced by ~task_scheduler_observer().

Here is the call graph for this function:
Here is the caller graph for this function:

## Friends And Related Function Documentation

## internal::observer_list

friend class internal::observer_list

friend

Definition at line 95 of file task_scheduler_observer.h.

## internal::observer_proxy

friend class internal::observer_proxy

friend

Definition at line 94 of file task_scheduler_observer.h.

## internal::task_scheduler_observer_v3

friend class internal::task_scheduler_observer_v3

friend

Definition at line 93 of file task_scheduler_observer.h.

## Member Data Documentation

## my_context_tag

intptr_t tbb::interface6::task_scheduler_observer::my_context_tag

private

contains task_arena pointer or tag indicating local or global semantics of the observer

Definition at line 103 of file task_scheduler_observer.h.

Referenced by task_scheduler_observer().

## v6_trait

const intptr_t tbb::interface6::task_scheduler_observer::v6_trait = (intptr_t)((~(uintptr_t)0 >> 1) + 1)

static private

Negative numbers with the largest absolute value to minimize probability of coincidence in case of a bug in busy count usage.

Definition at line 100 of file task_scheduler_observer.h.

Referenced by observe().

The documentation for this class was generated from the following file:

- task_scheduler_observer.h

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.