Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface5::internal::task_base Class Reference

Base class for methods that became static in TBB 3.0. More...

#include <task.h>

Inheritance diagram for tbb::interface5::internal::task_base:
Collaboration diagram for tbb::interface5::internal::task_base:

Static Private Member Functions

static void spawn (task &t)
 Schedule task for execution when a worker becomes available. More...
 
static void spawn (task_list &list)
 Spawn multiple tasks and clear list. More...
 
static tbb::internal::allocate_additional_child_of_proxy allocate_additional_child_of (task &t)
 Like allocate_child, except that task's parent becomes "t", not this. More...
 
static void __TBB_EXPORTED_FUNC destroy (task &victim)
 Destroy a task. More...
 

Private Attributes

__TBB_TASK_BASE_ACCESS __pad0__: friend class tbb::task
 

Additional Inherited Members

- Private Member Functions inherited from tbb::internal::no_copy
 no_copy (const no_copy &)=delete
 
 no_copy ()=default
 

Detailed Description

Base class for methods that became static in TBB 3.0.

TBB's evolution caused the "this" argument for several methods to become obsolete. However, for backwards binary compatibility, the new methods need distinct names, otherwise the One Definition Rule would be broken. Hence the new methods are defined in this private base class, and then exposed in class task via using declarations.

Definition at line 80 of file task.h.

Member Function Documentation

◆ allocate_additional_child_of()

static tbb::internal::allocate_additional_child_of_proxy tbb::interface5::internal::task_base::allocate_additional_child_of ( task t)
inlinestaticprivate

Like allocate_child, except that task's parent becomes "t", not this.

Typically used in conjunction with schedule_to_reexecute to implement while loops. Atomically increments the reference count of t.parent()

Definition at line 93 of file task.h.

◆ destroy()

void tbb::interface5::internal::task_base::destroy ( task victim)
staticprivate

Destroy a task.

Usually, calling this method is unnecessary, because a task is implicitly deleted after its execute() method runs. However, sometimes a task needs to be explicitly deallocated, such as when a root task is used as the parent in spawn_and_wait_for_all.

Definition at line 212 of file task.cpp.

212  {
213  // 1 may be a guard reference for wait_for_all, which was not reset because
214  // of concurrent_wait mode or because prepared root task was not actually used
215  // for spawning tasks (as in structured_task_group).
216  __TBB_ASSERT( (intptr_t)victim.prefix().ref_count <= 1, "Task being destroyed must not have children" );
217  __TBB_ASSERT( victim.state()==task::allocated, "illegal state for victim task" );
218  task* parent = victim.parent();
219  victim.~task();
220  if( parent ) {
221  __TBB_ASSERT( parent->state()!=task::freed && parent->state()!=task::ready,
222  "attempt to destroy child of running or corrupted parent?" );
223  // 'reexecute' and 'executing' are also signs of a race condition, since most tasks
224  // set their ref_count upon entry but "es_ref_count_active" should detect this
225  parent->internal_decrement_ref_count();
226  // Even if the last reference to *parent is removed, it should not be spawned (documented behavior).
227  }
229 }
void free_task(task &t)
Put task on free list.
Definition: scheduler.h:730
Disable caching for a small task.
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 parent
task is in ready pool, or is going to be put there, or was just taken off.
Definition: task.h:641
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 * task
static generic_scheduler * local_scheduler_weak()
Definition: governor.h:134
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
task object is on free list, or is going to be put there, or was just taken off.
Definition: task.h:645
task object is freshly allocated or recycled.
Definition: task.h:643

References __TBB_ASSERT, tbb::task::allocated, tbb::internal::generic_scheduler::free_task(), tbb::task::freed, tbb::internal::governor::local_scheduler_weak(), tbb::internal::no_cache, parent, tbb::task::parent(), tbb::task::prefix(), tbb::task::ready, tbb::internal::task_prefix::ref_count, tbb::task::state(), and tbb::task::~task().

Here is the call graph for this function:

◆ spawn() [1/2]

void tbb::interface5::internal::task_base::spawn ( task t)
inlinestaticprivate

Schedule task for execution when a worker becomes available.

Definition at line 1124 of file task.h.

1124  {
1125  t.prefix().owner->spawn( t, t.prefix().next );
1126 }

References tbb::internal::task_prefix::next, tbb::internal::task_prefix::owner, tbb::task::prefix(), and tbb::internal::scheduler::spawn().

Here is the call graph for this function:

◆ spawn() [2/2]

void tbb::interface5::internal::task_base::spawn ( task_list list)
inlinestaticprivate

Spawn multiple tasks and clear list.

Definition at line 1128 of file task.h.

1128  {
1129  if( task* t = list.first ) {
1130  t->prefix().owner->spawn( *t, *list.next_ptr );
1131  list.clear();
1132  }
1133 }
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 * task

References tbb::task_list::clear(), tbb::task_list::first, and tbb::task_list::next_ptr.

Here is the call graph for this function:

Member Data Documentation

◆ __pad0__

__TBB_TASK_BASE_ACCESS tbb::interface5::internal::task_base::__pad0__
private

Definition at line 82 of file task.h.


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

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.