Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface7::internal::delegated_task Class Reference
Inheritance diagram for tbb::interface7::internal::delegated_task:
Collaboration diagram for tbb::interface7::internal::delegated_task:

Public Member Functions

 delegated_task (internal::delegate_base &d, concurrent_monitor &s, task *t)
 
bool operator() (uintptr_t ctx) const
 
- Public Member Functions inherited from tbb::task
virtual ~task ()
 Destructor. More...
 
internal::allocate_continuation_proxyallocate_continuation ()
 Returns proxy for overloaded new that allocates a continuation task of *this. More...
 
internal::allocate_child_proxyallocate_child ()
 Returns proxy for overloaded new that allocates a child task of *this. More...
 
void recycle_as_continuation ()
 Change this to be a continuation of its former self. More...
 
void recycle_as_safe_continuation ()
 Recommended to use, safe variant of recycle_as_continuation. More...
 
void recycle_as_child_of (task &new_parent)
 Change this to be a child of new_parent. More...
 
void recycle_to_reexecute ()
 Schedule this for reexecution after current execute() returns. More...
 
void set_ref_count (int count)
 Set reference count. More...
 
void increment_ref_count ()
 Atomically increment reference count. More...
 
int add_ref_count (int count)
 Atomically adds to reference count and returns its new value. More...
 
int decrement_ref_count ()
 Atomically decrement reference count and returns its new value. More...
 
void spawn_and_wait_for_all (task &child)
 Similar to spawn followed by wait_for_all, but more efficient. More...
 
void __TBB_EXPORTED_METHOD spawn_and_wait_for_all (task_list &list)
 Similar to spawn followed by wait_for_all, but more efficient. More...
 
void wait_for_all ()
 Wait for reference count to become one, and set reference count to zero. More...
 
taskparent () const
 task on whose behalf this task is working, or NULL if this is a root. More...
 
void set_parent (task *p)
 sets parent task pointer to specified value More...
 
task_group_contextcontext ()
 This method is deprecated and will be removed in the future. More...
 
task_group_contextgroup ()
 Pointer to the task group descriptor. More...
 
bool is_stolen_task () const
 True if task was stolen from the task pool of another thread. More...
 
bool is_enqueued_task () const
 True if the task was enqueued. More...
 
state_type state () const
 Current execution state. More...
 
int ref_count () const
 The internal reference count. More...
 
bool __TBB_EXPORTED_METHOD is_owned_by_current_thread () const
 Obsolete, and only retained for the sake of backward compatibility. Always returns true. More...
 
void set_affinity (affinity_id id)
 Set affinity for this task. More...
 
affinity_id affinity () const
 Current affinity of this task. More...
 
virtual void __TBB_EXPORTED_METHOD note_affinity (affinity_id id)
 Invoked by scheduler to notify task that it ran on unexpected thread. More...
 
void __TBB_EXPORTED_METHOD change_group (task_group_context &ctx)
 Moves this task from its current group into another one. More...
 
bool cancel_group_execution ()
 Initiates cancellation of all tasks in this cancellation group and its subordinate groups. More...
 
bool is_cancelled () const
 Returns true if the context has received cancellation request. More...
 
__TBB_DEPRECATED void set_group_priority (priority_t p)
 Changes priority of the task group this task belongs to. More...
 
__TBB_DEPRECATED priority_t group_priority () const
 Retrieves current priority of the task group this task belongs to. More...
 

Private Member Functions

taskexecute () __TBB_override
 Should be overridden by derived classes. More...
 
 ~delegated_task ()
 

Private Attributes

internal::delegate_basemy_delegate
 
concurrent_monitormy_monitor
 
taskmy_root
 

Additional Inherited Members

- Public Types inherited from tbb::task
enum  state_type {
  executing, reexecute, ready, allocated,
  freed, recycle
}
 Enumeration of task states that the scheduler considers. More...
 
typedef internal::affinity_id affinity_id
 An id as used for specifying affinity. More...
 
- Static Public Member Functions inherited from tbb::task
static internal::allocate_root_proxy allocate_root ()
 Returns proxy for overloaded new that allocates a root task. More...
 
static internal::allocate_root_with_context_proxy allocate_root (task_group_context &ctx)
 Returns proxy for overloaded new that allocates a root task associated with user supplied context. More...
 
static void spawn_root_and_wait (task &root)
 Spawn task allocated by allocate_root, wait for it to complete, and deallocate it. More...
 
static void spawn_root_and_wait (task_list &root_list)
 Spawn root tasks on list and wait for all of them to finish. More...
 
static void enqueue (task &t)
 Enqueue task for starvation-resistant execution. More...
 
static __TBB_DEPRECATED void enqueue (task &t, priority_t p)
 Enqueue task for starvation-resistant execution on the specified priority level. More...
 
static __TBB_DEPRECATED void enqueue (task &t, task_arena &arena, priority_t p=priority_t(0))
 Enqueue task in task_arena. More...
 
static task &__TBB_EXPORTED_FUNC self ()
 The innermost task being executed or destroyed by the current thread at the moment. More...
 
- Protected Member Functions inherited from tbb::task
 task ()
 Default constructor. More...
 

Detailed Description

Definition at line 889 of file arena.cpp.

Constructor & Destructor Documentation

◆ ~delegated_task()

tbb::interface7::internal::delegated_task::~delegated_task ( )
inlineprivate

Definition at line 926 of file arena.cpp.

References __TBB_ASSERT, tbb::internal::__TBB_store_with_release(), tbb::internal::concurrent_monitor::notify(), tbb::task::prefix(), and tbb::task::ref_count().

926  {
927  // potential exception was already registered. It must happen before the notification
928  __TBB_ASSERT(my_root->ref_count() == 2, NULL);
929  task_prefix& prefix = my_root->prefix();
930 #if __TBB_PREVIEW_RESUMABLE_TASKS
931  reference_count old_ref_count = __TBB_FetchAndStoreW(&prefix.ref_count, 1);
932  // Check if the scheduler was abandoned.
933  if (old_ref_count == internal::abandon_flag + 2) {
934  __TBB_ASSERT(prefix.abandoned_scheduler, NULL);
935  // The wait has been completed. Spawn a resume task.
936  tbb::task::resume(prefix.abandoned_scheduler);
937  }
938 #else
939  __TBB_store_with_release(prefix.ref_count, 1); // must precede the wakeup
940 #endif
941  my_monitor.notify(*this); // do not relax, it needs a fence!
942  }
void __TBB_store_with_release(volatile T &location, V value)
Definition: tbb_machine.h:716
intptr_t reference_count
A reference count.
Definition: task.h:120
internal::task_prefix & prefix(internal::version_tag *=NULL) const
Get reference to corresponding task_prefix.
Definition: task.h:991
int ref_count() const
The internal reference count.
Definition: task.h:904
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
void notify(const P &predicate)
Notify waiting threads of the event that satisfies the given predicate.
Here is the call graph for this function:

◆ delegated_task()

tbb::interface7::internal::delegated_task::delegated_task ( internal::delegate_base d,
concurrent_monitor s,
task t 
)
inline

Definition at line 944 of file arena.cpp.

945  : my_delegate(d), my_monitor(s), my_root(t) {}
void const char const char int ITT_FORMAT __itt_group_sync s
internal::delegate_base & my_delegate
Definition: arena.cpp:890
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d

Member Function Documentation

◆ execute()

task* tbb::interface7::internal::delegated_task::execute ( )
inlineprivatevirtual

Should be overridden by derived classes.

Implements tbb::task.

Definition at line 893 of file arena.cpp.

References __TBB_ASSERT, tbb::internal::scheduler_properties::master, tbb::internal::scheduler_state::my_arena, tbb::internal::generic_scheduler::my_dummy_task, tbb::internal::scheduler_state::my_innermost_running_task, tbb::internal::scheduler_state::my_properties, tbb::internal::generic_scheduler::outermost_level(), s, scope, and tbb::internal::scheduler_properties::type.

893  {
894  generic_scheduler& s = *(generic_scheduler*)prefix().owner;
895  __TBB_ASSERT(s.outermost_level(), "expected to be enqueued and received on the outermost level");
896  struct outermost_context : internal::no_copy {
897  delegated_task * t;
898  generic_scheduler & s;
899  task * orig_dummy;
900  task_group_context * orig_ctx;
901  scheduler_properties orig_props;
902  outermost_context(delegated_task *_t, generic_scheduler &_s)
903  : t(_t), s(_s), orig_dummy(s.my_dummy_task), orig_props(s.my_properties) {
904  __TBB_ASSERT(s.my_innermost_running_task == t, NULL);
905 #if __TBB_TASK_GROUP_CONTEXT
906  orig_ctx = t->prefix().context;
907  t->prefix().context = s.my_arena->my_default_ctx;
908 #endif
909  // Mimics outermost master
910  s.my_dummy_task = t;
911  s.my_properties.type = scheduler_properties::master;
912  }
913  ~outermost_context() {
914 #if __TBB_TASK_GROUP_CONTEXT
915  // Restore context for sake of registering potential exception
916  t->prefix().context = orig_ctx;
917 #endif
918  // Restore scheduler state
919  s.my_properties = orig_props;
920  s.my_dummy_task = orig_dummy;
921  }
922  } scope(this, s);
923  my_delegate();
924  return NULL;
925  }
delegated_task(internal::delegate_base &d, concurrent_monitor &s, task *t)
Definition: arena.cpp:944
void const char const char int ITT_FORMAT __itt_group_sync s
internal::task_prefix & prefix(internal::version_tag *=NULL) const
Get reference to corresponding task_prefix.
Definition: task.h:991
internal::delegate_base & my_delegate
Definition: arena.cpp:890
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d __itt_event ITT_FORMAT __itt_group_mark d void const wchar_t const wchar_t int ITT_FORMAT __itt_group_sync __itt_group_fsync x void const wchar_t int const wchar_t int int ITT_FORMAT __itt_group_sync __itt_group_fsync x void ITT_FORMAT __itt_group_sync __itt_group_fsync p void ITT_FORMAT __itt_group_sync __itt_group_fsync p void size_t ITT_FORMAT lu no args __itt_obj_prop_t __itt_obj_state_t ITT_FORMAT d const char ITT_FORMAT s __itt_frame ITT_FORMAT p const char const char ITT_FORMAT s __itt_counter ITT_FORMAT p __itt_counter unsigned long long ITT_FORMAT lu const wchar_t ITT_FORMAT S __itt_mark_type const wchar_t ITT_FORMAT S __itt_mark_type const char ITT_FORMAT s __itt_mark_type ITT_FORMAT d __itt_caller ITT_FORMAT p __itt_caller ITT_FORMAT p no args const __itt_domain __itt_clock_domain unsigned long long __itt_id ITT_FORMAT lu const __itt_domain __itt_clock_domain unsigned long long __itt_id __itt_id void ITT_FORMAT p const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_clock_domain unsigned long long __itt_id __itt_string_handle __itt_scope scope
scheduler * owner
Obsolete. The scheduler that owns the task.
Definition: task.h:236
task()
Default constructor.
Definition: task.h:614
Here is the call graph for this function:

◆ operator()()

bool tbb::interface7::internal::delegated_task::operator() ( uintptr_t  ctx) const
inline

Definition at line 947 of file arena.cpp.

947 { return (void*)ctx == (void*)&my_delegate; }
internal::delegate_base & my_delegate
Definition: arena.cpp:890

Member Data Documentation

◆ my_delegate

internal::delegate_base& tbb::interface7::internal::delegated_task::my_delegate
private

Definition at line 890 of file arena.cpp.

◆ my_monitor

concurrent_monitor& tbb::interface7::internal::delegated_task::my_monitor
private

Definition at line 891 of file arena.cpp.

◆ my_root

task* tbb::interface7::internal::delegated_task::my_root
private

Definition at line 892 of file arena.cpp.


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

Copyright © 2005-2019 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.