tbb::internal::task_prefix Class Reference
Task Scheduling

Memory prefix to a task object. More...

`#include <task.h>`

Collaboration diagram for tbb::internal::task_prefix:

## Private Member Functions

tbb::task & | task ()
| The task corresponding to this task_prefix. More...

## Private Attributes

isolation_tag | isolation
| The tag used for task isolation. More...
task_group_context * | context
| Shared context that is used to communicate asynchronous state changes. More...
scheduler * | origin
| The scheduler that allocated the task, or NULL if the task is big. More...
union {
scheduler * owner
| Obsolete. The scheduler that owns the task. More...
task * next_offloaded
| Pointer to the next offloaded lower priority task. More...
}; |
tbb::task * | parent
| The task whose reference count includes me. More...
__TBB_atomic reference_count | ref_count
| Reference count used for synchronization. More...
int | depth
| Obsolete. Used to be scheduling depth before TBB 2.2. More...
unsigned char | state
| A task::state_type, stored as a byte for compactness. More...
unsigned char | extra_state
| Miscellaneous state that is not directly visible to users, stored as a byte for compactness. More...
affinity_id | affinity
tbb::task * | next
| "next" field for list of task More...

## Friends

class | tbb::task
class | tbb::interface5::internal::task_base
class | tbb::task_list
class | internal::scheduler
class | internal::allocate_root_proxy
class | internal::allocate_child_proxy
class | internal::allocate_continuation_proxy
class | internal::allocate_additional_child_of_proxy
void | make_critical (task &)
bool | is_critical (task &)

## Detailed Description

Memory prefix to a task object.

This class is internal to the library. Do not reference it directly, except within the library itself. Fields are ordered in way that preserves backwards compatibility and yields good packing on typical 32-bit and 64-bit platforms. New fields should be added at the beginning for backward compatibility with accesses to the task prefix inlined into application code. To prevent ODR violation, the class shall have the same layout in all application translation units. If some fields are conditional (e.g. enabled by preview macros) and might get skipped, use reserved fields to adjust the layout.

In case task prefix size exceeds 32 or 64 bytes on IA32 and Intel64 architectures correspondingly, consider dynamic setting of task_alignment and task_prefix_reservation_size based on the maximal operand size supported by the current CPU.

Definition at line 203 of file task.h.

## Member Function Documentation

## task()

tbb::task& tbb::internal::task_prefix::task | ( |  | ) |

inline private

The task corresponding to this task_prefix.

Definition at line 300 of file task.h.

{return *reinterpret_cast<tbb::task*>(this+1);}
tbb::task
Base class for user-defined tasks.
Definition: task.h:615

## Friends And Related Function Documentation

## internal::allocate_additional_child_of_proxy

friend class internal::allocate_additional_child_of_proxy

friend

Definition at line 212 of file task.h.

## internal::allocate_child_proxy

friend class internal::allocate_child_proxy

friend

Definition at line 210 of file task.h.

## internal::allocate_continuation_proxy

friend class internal::allocate_continuation_proxy

friend

Definition at line 211 of file task.h.

## internal::allocate_root_proxy

friend class internal::allocate_root_proxy

friend

Definition at line 209 of file task.h.

## internal::scheduler

friend class internal::scheduler

friend

Definition at line 208 of file task.h.

## is_critical

bool is_critical | ( | task & | t | ) |

friend

Definition at line 1014 of file task.h.

{ return bool((t.prefix().extra_state & 0x8) != 0); }

## make_critical

void make_critical | ( | task & | t | ) |

friend

Definition at line 1013 of file task.h.

{ t.prefix().extra_state |= 0x8; }

## tbb::interface5::internal::task_base

friend class tbb::interface5::internal::task_base

friend

Definition at line 206 of file task.h.

## tbb::task

friend class tbb::task

friend

Definition at line 205 of file task.h.

## tbb::task_list

friend class tbb::task_list

friend

Definition at line 207 of file task.h.

## Member Data Documentation

##

union { ... }

## affinity

affinity_id tbb::internal::task_prefix::affinity

private

Definition at line 294 of file task.h.

Referenced by tbb::internal::arena::enqueue_task(), tbb::internal::generic_scheduler::prepare_for_spawning(), and tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop().

## context

task_group_context* tbb::internal::task_prefix::context

private

Shared context that is used to communicate asynchronous state changes.

Currently it is used to broadcast cancellation requests generated both by users and as the result of unhandled exceptions in the task::execute() methods.

Definition at line 230 of file task.h.

Referenced by tbb::internal::allocate_additional_child_of_proxy::allocate(), tbb::internal::allocate_continuation_proxy::allocate(), tbb::internal::allocate_child_proxy::allocate(), tbb::internal::generic_scheduler::attach_arena(), tbb::internal::generic_scheduler::create_master(), tbb::internal::generic_scheduler::local_spawn_root_and_wait(), tbb::internal::nested_arena_context::mimic_outermost_level(), tbb::internal::generic_scheduler::prepare_for_spawning(), tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop(), tbb::task::recycle_as_child_of(), and tbb::internal::nested_arena_context::~nested_arena_context().

## depth

int tbb::internal::task_prefix::depth

private

Obsolete. Used to be scheduling depth before TBB 2.2.

Retained only for the sake of backward binary compatibility. Not used by TBB anymore.

Definition at line 279 of file task.h.

## extra_state

unsigned char tbb::internal::task_prefix::extra_state

private

Miscellaneous state that is not directly visible to users, stored as a byte for compactness.

0x0 -> version 1.0 task 0x1 -> version >=2.1 task 0x10 -> task was enqueued 0x20 -> task_proxy 0x40 -> task has live ref_count 0x80 -> a stolen task

Definition at line 292 of file task.h.

Referenced by tbb::internal::arena::enqueue_task(), tbb::internal::generic_scheduler::is_proxy(), tbb::internal::generic_scheduler::is_version_3_task(), tbb::internal::generic_scheduler::prepare_for_spawning(), tbb::internal::reset_extra_state(), and tbb::internal::generic_scheduler::steal_task().

## isolation

isolation_tag tbb::internal::task_prefix::isolation

private

The tag used for task isolation.

Definition at line 220 of file task.h.

Referenced by tbb::internal::arena::enqueue_task(), tbb::internal::generic_scheduler::get_task(), tbb::internal::mail_outbox::internal_pop(), tbb::internal::custom_scheduler< SchedulerTraits >::local_wait_for_all(), tbb::internal::task_stream< Levels >::look_specific(), tbb::internal::generic_scheduler::prepare_for_spawning(), tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop(), and tbb::internal::generic_scheduler::steal_task_from().

## next

tbb::task* tbb::internal::task_prefix::next

private

"next" field for list of task

Definition at line 297 of file task.h.

Referenced by tbb::internal::generic_scheduler::allocate_task(), tbb::internal::generic_scheduler::cleanup_scheduler(), tbb::internal::generic_scheduler::free_nonlocal_small_task(), tbb::internal::generic_scheduler::local_spawn(), tbb::internal::generic_scheduler::local_spawn_root_and_wait(), tbb::internal::custom_scheduler< SchedulerTraits >::local_wait_for_all(), tbb::task_list::pop_front(), tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop(), tbb::task_list::push_back(), tbb::interface5::internal::task_base::spawn(), tbb::task::spawn_and_wait_for_all(), tbb::task::spawn_root_and_wait(), and tbb::internal::custom_scheduler< SchedulerTraits >::tally_completion_of_predecessor().

## next_offloaded

task* tbb::internal::task_prefix::next_offloaded

Pointer to the next offloaded lower priority task.

Used to maintain a list of offloaded tasks inside the scheduler.

Definition at line 252 of file task.h.

Referenced by tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop().

## origin

scheduler* tbb::internal::task_prefix::origin

private

The scheduler that allocated the task, or NULL if the task is big.

Small tasks are pooled by the scheduler that allocated the task. If a scheduler needs to free a small task allocated by another scheduler, it returns the task to that other scheduler. This policy avoids memory space blowup issues for memory allocators that allocate from thread-specific pools.

Definition at line 239 of file task.h.

Referenced by tbb::internal::generic_scheduler::allocate_task(), and tbb::internal::generic_scheduler::free_nonlocal_small_task().

## owner

scheduler* tbb::internal::task_prefix::owner

Obsolete. The scheduler that owns the task.

Retained only for the sake of backward binary compatibility. Still used by inline methods in the task.h header.

Definition at line 247 of file task.h.

Referenced by tbb::task::enqueue(), tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop(), tbb::interface5::internal::task_base::spawn(), tbb::task::spawn_root_and_wait(), and tbb::internal::generic_scheduler::steal_task().

## parent

tbb::task* tbb::internal::task_prefix::parent

private

The task whose reference count includes me.

In the "blocking style" of programming, this field points to the parent task. In the "continuation-passing style" of programming, this field points to the continuation of the parent.

Definition at line 267 of file task.h.

Referenced by tbb::internal::allocate_continuation_proxy::allocate(), and tbb::internal::generic_scheduler::local_spawn_root_and_wait().

## ref_count

__TBB_atomic reference_count tbb::internal::task_prefix::ref_count

private

Reference count used for synchronization.

In the "continuation-passing style" of programming, this field is the difference of the number of allocated children minus the number of children that have completed. In the "blocking style" of programming, this field is one more than the difference.

Definition at line 274 of file task.h.

Referenced by tbb::internal::generic_scheduler::create_master(), tbb::interface5::internal::task_base::destroy(), tbb::internal::generic_scheduler::generic_scheduler(), tbb::internal::generic_scheduler::local_spawn_root_and_wait(), tbb::internal::custom_scheduler< SchedulerTraits >::local_wait_for_all(), tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop(), and tbb::internal::generic_scheduler::wait_until_empty().

## state

unsigned char tbb::internal::task_prefix::state

private

A task::state_type, stored as a byte for compactness.

This state is exposed to users via method task::state().

Definition at line 283 of file task.h.

Referenced by tbb::internal::arena::enqueue_task(), tbb::internal::custom_scheduler< SchedulerTraits >::local_wait_for_all(), tbb::internal::generic_scheduler::prepare_for_spawning(), tbb::internal::custom_scheduler< SchedulerTraits >::process_bypass_loop(), and tbb::task::recycle_as_child_of().

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

- task.h

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.