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

inline static private

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.

{
return tbb::internal::allocate_additional_child_of_proxy(t);
}
tbb::internal::allocate_additional_child_of_proxy
Definition: task.h:57

## destroy()

void tbb::interface5::internal::task_base::destroy | ( | task & | victim | ) |

static private

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.

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

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, tbb::task::parent(), 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 | ) |

inline static private

Schedule task for execution when a worker becomes available.

Definition at line 1124 of file task.h.

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

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

inline static private

Spawn multiple tasks and clear list.

Definition at line 1128 of file task.h.

{
if( task* t = list.first ) {
t->prefix().owner->spawn( *t, *list.next_ptr );
list.clear();
}
}

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 81 of file task.h.

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

- task.h
- task.cpp

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.