21 #ifndef __TBB_task_scheduler_observer_H 22 #define __TBB_task_scheduler_observer_H 25 #if __TBB_ARENA_OBSERVER || __TBB_SLEEP_PERMISSION 26 #include "task_arena.h" 29 #if __TBB_SCHEDULER_OBSERVER 32 namespace interface6 {
33 class task_scheduler_observer;
41 friend class observer_proxy;
42 friend class observer_list;
43 friend class interface6::task_scheduler_observer;
47 observer_proxy* my_proxy;
59 void __TBB_EXPORTED_METHOD
observe(
bool state=
true );
91 #if __TBB_ARENA_OBSERVER || __TBB_SLEEP_PERMISSION 92 namespace interface6 {
95 friend class internal::observer_proxy;
96 friend class internal::observer_list;
101 static const intptr_t v6_trait = (intptr_t)((~(uintptr_t)0 >> 1) + 1);
104 intptr_t my_context_tag;
105 enum { global_tag = 0, implicit_tag = 1 };
119 #if __TBB_ARENA_OBSERVER 120 my_context_tag = local? implicit_tag : global_tag;
122 __TBB_ASSERT_EX( !local, NULL );
123 my_context_tag = global_tag;
127 #if __TBB_ARENA_OBSERVER 133 my_context_tag = (intptr_t)&a;
145 void observe(
bool state=
true ) {
146 if( state && !my_proxy ) {
147 __TBB_ASSERT( !my_busy_count,
"Inconsistent state of task_scheduler_observer instance");
148 my_busy_count.store<
relaxed>(v6_trait);
153 #if __TBB_SLEEP_PERMISSION 154 enum { keep_awake =
false, allow_sleep =
true };
160 virtual bool may_sleep() {
return allow_sleep; }
165 using interface6::task_scheduler_observer;
virtual void on_scheduler_entry(bool)
Entry notification.
Definition: task_scheduler_observer.h:75
No ordering.
Definition: atomic.h:51
bool is_observing() const
Returns true if observation is enabled, false otherwise.
Definition: task_scheduler_observer.h:62
virtual ~task_scheduler_observer_v3()
Destructor automatically switches observation off if it is enabled.
Definition: task_scheduler_observer.h:86
Definition: _flow_graph_async_msg_impl.h:32
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
1-to-1 proxy representation class of scheduler's arena Constructors set up settings only...
Definition: task_arena.h:120
void __TBB_EXPORTED_METHOD observe(bool state=true)
Enable or disable observation.
Definition: task_scheduler_observer.h:40
task_scheduler_observer_v3()
Construct observer with observation disabled.
Definition: task_scheduler_observer.h:65
virtual void on_scheduler_exit(bool)
Exit notification.
Definition: task_scheduler_observer.h:83