Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
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

Constructor & Destructor Documentation

◆ task_scheduler_observer() [1/2]

tbb::interface6::task_scheduler_observer::task_scheduler_observer ( bool  local = false)
inlineexplicit

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.

117  {
118 #if __TBB_ARENA_OBSERVER
120 #else
121  __TBB_ASSERT_EX( !local, NULL );
123 #endif
124  }
intptr_t my_context_tag
contains task_arena pointer or tag indicating local or global semantics of the observer
#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

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)
inlineexplicit

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.

131  {
132  my_context_tag = (intptr_t)&a;
133  }
intptr_t my_context_tag
contains task_arena pointer or tag indicating local or global semantics of the observer

References my_context_tag.

◆ ~task_scheduler_observer()

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

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.

139 { if(my_proxy) observe(false); }
void observe(bool state=true)
Enable or disable observation.
observer_proxy * my_proxy
Pointer to the proxy holding this observer.

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.

144  {
145  if( state && !my_proxy ) {
146  __TBB_ASSERT( !my_busy_count, "Inconsistent state of task_scheduler_observer instance");
148  }
150  }
void __TBB_EXPORTED_METHOD observe(bool state=true)
Enable or disable observation.
atomic< intptr_t > my_busy_count
Counter preventing the observer from being destroyed while in use by the scheduler.
No ordering.
Definition: atomic.h:61
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
observer_proxy * my_proxy
Pointer to the proxy holding this observer.

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

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)
staticprivate

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:

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.