31 class task_group_context;
35 #if _MSC_VER || (__GNUC__==3 && __GNUC_MINOR__<3) 36 #define __TBB_TASK_BASE_ACCESS public 38 #define __TBB_TASK_BASE_ACCESS private 58 namespace interface5 {
112 virtual void enqueue(
task& t,
void* reserved ) = 0;
122 #if __TBB_TASK_ISOLATION 128 #if __TBB_TASK_GROUP_CONTEXT 163 #if __TBB_PREVIEW_CRITICAL_TASKS 194 #if __TBB_PREVIEW_CRITICAL_TASKS 199 #if __TBB_TASK_ISOLATION 203 intptr_t reserved_space_for_task_isolation_tag;
206 #if __TBB_TASK_GROUP_CONTEXT 222 #if __TBB_TASK_PRIORITY 230 #if __TBB_TASK_PRIORITY 280 #if __TBB_TASK_GROUP_CONTEXT 282 #if __TBB_TASK_PRIORITY 285 #if __TBB_PREVIEW_CRITICAL_TASKS 299 #if TBB_USE_CAPTURED_EXCEPTION 303 class tbb_exception_ptr;
307 class task_scheduler_init;
308 namespace interface7 {
class task_arena; }
309 using interface7::task_arena;
338 #if TBB_USE_CAPTURED_EXCEPTION 362 #if TBB_USE_CAPTURED_EXCEPTION 399 - 2 *
sizeof(uintptr_t)-
sizeof(
void*) -
sizeof(internal::context_list_node_t)
402 -
sizeof(internal::cpu_ctl_env_space)
431 #if __TBB_TASK_PRIORITY 442 #if __TBB_TASK_PRIORITY 480 :
my_kind(relation_with_parent)
482 ,
my_name(internal::CUSTOM_CTX)
543 #if __TBB_TASK_PRIORITY 569 template <
typename T>
573 void bind_to ( internal::generic_scheduler *local_sched );
576 void register_with ( internal::generic_scheduler *local_sched );
622 #if __TBB_RECYCLE_TO_ENQUEUE 637 #if __TBB_TASK_GROUP_CONTEXT 640 return internal::allocate_root_with_context_proxy(ctx);
647 return *reinterpret_cast<internal::allocate_continuation_proxy*>(
this);
652 return *reinterpret_cast<internal::allocate_child_proxy*>(
this);
656 using task_base::allocate_additional_child_of;
658 #if __TBB_DEPRECATED_TASK_INTERFACE 666 using task_base::destroy;
696 internal::task_prefix&
p =
prefix();
703 p.parent = &new_parent;
704 #if __TBB_TASK_GROUP_CONTEXT 705 p.context = new_parent.
prefix().context;
717 #if __TBB_RECYCLE_TO_ENQUEUE 720 void recycle_to_enqueue() {
722 prefix().state = to_enqueue;
732 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 750 __TBB_ASSERT( k>=0,
"task's reference count underflowed" );
759 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 767 using task_base::spawn;
771 prefix().owner->wait_for_all( *
this, &child );
779 root.
prefix().owner->spawn_root_and_wait( root, root.
prefix().next );
790 prefix().owner->wait_for_all( *
this, NULL );
794 #if __TBB_TASK_PRIORITY 807 t.
prefix().owner->enqueue( t, NULL );
810 #if __TBB_TASK_PRIORITY 813 #if __TBB_PREVIEW_CRITICAL_TASKS 819 t.
prefix().owner->enqueue( t, (
void*)
p );
825 inline static void enqueue(
task& t, task_arena& arena
839 #if __TBB_TASK_GROUP_CONTEXT 845 #if __TBB_TASK_GROUP_CONTEXT 856 return (
prefix().extra_state & 0x80)!=0;
870 __TBB_ASSERT( ref_count_==
int(ref_count_),
"integer overflow error");
899 #if __TBB_TASK_GROUP_CONTEXT 923 #if __TBB_TASK_PRIORITY 937 #if __TBB_TASK_GROUP_CONTEXT 947 return reinterpret_cast<internal::task_prefix*>(const_cast<task*>(
this))[-1];
949 #if __TBB_PREVIEW_CRITICAL_TASKS 955 #if __TBB_PREVIEW_CRITICAL_TASKS 974 #if __TBB_ALLOW_MUTABLE_FUNCTORS 985 #if __TBB_CPP11_RVALUE_REF_PRESENT 1051 t->prefix().owner->spawn( *t, *list.
next_ptr );
1058 t->prefix().owner->spawn_root_and_wait( *t, *root_list.
next_ptr );
1073 #if __TBB_TASK_GROUP_CONTEXT 1075 return &
p.allocate(bytes);
1079 p.free( *static_cast<tbb::task*>(
task) );
1084 return &
p.allocate(bytes);
1088 p.free( *static_cast<tbb::task*>(
task) );
1092 return &
p.allocate(bytes);
1096 p.free( *static_cast<tbb::task*>(
task) );
1100 return &
p.allocate(bytes);
1104 p.free( *static_cast<tbb::task*>(
task) );
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
static void enqueue(task &t)
Enqueue task for starvation-resistant execution.
virtual ~scheduler()=0
Pure virtual destructor;.
friend class internal::scheduler
friend class internal::generic_scheduler
state_type
Enumeration of task states that the scheduler considers.
task_group_context & my_context
uintptr_t my_cancellation_requested
Specifies whether cancellation was requested for this task group.
static const int priority_critical
bool is_stolen_task() const
True if task was stolen from the task pool of another thread.
priority_t group_priority() const
Retrieves current priority of the task group this task belongs to.
bool __TBB_EXPORTED_METHOD is_owned_by_current_thread() const
Obsolete, and only retained for the sake of backward compatibility. Always returns true.
static const int priority_stride_v4
internal::tbb_exception_ptr exception_container_type
#define __TBB_TASK_PRIORITY
void propagate_task_group_state(T task_group_context::*mptr_state, task_group_context &src, T new_state)
Propagates any state change detected to *this, and as an optimisation possibly also upward along the ...
exception_container_type * my_exception
Pointer to the container storing exception being propagated across this task group.
task_group_context(kind_type relation_with_parent=bound, uintptr_t t=default_traits)
Default & binding constructor.
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.
static task &__TBB_EXPORTED_FUNC allocate(size_t size)
allocate_root_with_context_proxy(task_group_context &ctx)
intptr_t reference_count
A reference count.
#define __TBB_EXPORTED_METHOD
void make_critical(task &t)
friend class internal::scheduler
task_group_context * context()
This method is deprecated and will be removed in the future.
task * next_offloaded
Pointer to the next offloaded lower priority task.
intptr_t my_priority
Priority level of the task group (in normalized representation)
task * execute() __TBB_override
Should be overridden by derived classes.
void spawn_and_wait_for_all(task &child)
Similar to spawn followed by wait_for_all, but more efficient.
friend class internal::allocate_continuation_proxy
char _leading_padding[internal::NFS_MaxLineSize - 2 *sizeof(uintptr_t) - sizeof(void *) - sizeof(internal::context_list_node_t) - sizeof(__itt_caller) - sizeof(internal::cpu_ctl_env_space)]
Leading padding protecting accesses to frequently used members from false sharing.
bool __TBB_EXPORTED_METHOD cancel_group_execution()
Initiates cancellation of all tasks in this cancellation group and its subordinate groups.
friend bool is_critical(task &)
char _trailing_padding[internal::NFS_MaxLineSize - 2 *sizeof(uintptr_t) - 2 *sizeof(void *) - sizeof(intptr_t) - sizeof(internal::string_index)]
Trailing padding protecting accesses to frequently used members from false sharing.
virtual ~task()
Destructor.
virtual void enqueue(task &t, void *reserved)=0
For internal use only.
internal::string_index my_name
Description of algorithm for scheduler based instrumentation.
friend void make_critical(task &)
Memory prefix to a task object.
context_list_node_t * my_prev
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
void __TBB_EXPORTED_METHOD free(task &) const
virtual void wait_for_all(task &parent, task *child)=0
For internal use only.
void __TBB_EXPORTED_METHOD init()
Out-of-line part of the constructor.
#define __TBB_FetchAndDecrementWrelease(P)
friend class internal::allocate_additional_child_of_proxy
friend class internal::allocate_root_with_context_proxy
internal::reference_count __TBB_EXPORTED_METHOD internal_decrement_ref_count()
Decrement reference count and return its new value.
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
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 count
context_list_node_t * my_next
#define __TBB_EXPORTED_FUNC
void set_group_priority(priority_t p)
Changes priority of the task group this task belongs to.
state_type state() const
Current execution state.
auto first(Container &c) -> decltype(begin(c))
void __TBB_EXPORTED_METHOD free(task &) const
void register_with(internal::generic_scheduler *local_sched)
Registers this context with the local scheduler.
virtual void spawn_root_and_wait(task &first, task *&next)=0
For internal use only.
task_list()
Construct empty list.
task that does nothing. Useful for synchronization.
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
void __TBB_EXPORTED_METHOD free(task &) const
Used to form groups of tasks.
task object is freshly allocated or recycled.
tbb::task & task()
The task corresponding to this task_prefix.
static void spawn(task &t)
Schedule task for execution when a worker becomes available.
internal::task_prefix & prefix(internal::version_tag *=NULL) const
Get reference to corresponding task_prefix.
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
task * execute() __TBB_override
Should be overridden by derived classes.
unsigned short affinity_id
An id as used for specifying affinity.
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
task()
Default constructor.
void suppress_unused_warning(const T1 &)
Utility template function to prevent "unused" warnings by various compilers.
Base class for types that should not be copied or assigned.
static const kind_type dying
bool is_cancelled() const
Returns true if the context has received cancellation request.
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
uintptr_t traits() const
Returns the context's trait.
friend class internal::allocate_continuation_proxy
internal::cpu_ctl_env_space my_cpu_ctl_env
Space for platform-specific FPU settings.
scheduler * owner
Obsolete. The scheduler that owns the task.
task_group_context(internal::string_index name)
__TBB_atomic kind_type my_kind
Flavor of this context: bound or isolated.
void bind_to(internal::generic_scheduler *local_sched)
Registers this context with the local scheduler and binds it to its parent context.
tbb::task * parent
The task whose reference count includes me.
bool empty() const
True if list is empty; false otherwise.
task object is on free list, or is going to be put there, or was just taken off.
task * self
No longer used, but retained for binary layout compatibility. Always NULL.
#define __TBB_FetchAndIncrementWacquire(P)
void recycle_as_child_of(task &new_parent)
Change this to be a child of new_parent.
bool cancel_group_execution()
Initiates cancellation of all tasks in this cancellation group and its subordinate groups.
tbb::task * next
"next" field for list of 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
unsigned char state
A task::state_type, stored as a byte for compactness.
__TBB_atomic reference_count ref_count
Reference count used for synchronization.
isolation_tag isolation
The tag used for task isolation.
Interface to be implemented by all exceptions TBB recognizes and propagates across the threads.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Class delimiting the scope of task scheduler activity.
uintptr_t my_state
Internal state (combination of state flags, currently only may_have_children).
void push_back(task &task)
Push task onto back of list.
int decrement_ref_count()
Atomically decrement reference count and returns its new value.
Base class for methods that became static in TBB 3.0.
int depth
Obsolete. Used to be scheduling depth before TBB 2.2.
task & pop_front()
Pop the front task from the list.
__TBB_EXPORTED_METHOD ~task_group_context()
void move(tbb_thread &t1, tbb_thread &t2)
unsigned char extra_state
Miscellaneous state that is not directly visible to users, stored as a byte for compactness.
priority_t priority() const
Retrieves current priority of the current task group.
void set_ref_count(int count)
Set reference count.
static const kind_type detached
internal::affinity_id affinity_id
An id as used for specifying affinity.
scheduler * origin
The scheduler that allocated the task, or NULL if the task is big.
Base class for user-defined tasks.
virtual void spawn(task &first, task *&next)=0
For internal use only.
friend class internal::allocate_child_proxy
void set_priority(priority_t)
Changes priority of the task group.
Work stealing task scheduler.
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
virtual task * execute()=0
Should be overridden by derived classes.
internal::context_list_node_t my_node
Used to form the thread specific list of contexts without additional memory allocation.
void recycle_to_reexecute()
Schedule this for reexecution after current execute() returns.
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
task_group_context * group()
Pointer to the task group descriptor.
void set_parent(task *p)
sets parent task pointer to specified value
~task_list()
Destroys the list, but does not destroy the task objects.
void copy_fp_settings(const task_group_context &src)
Copies FPU control setting from another context.
bool is_critical(task &t)
Base class for types that should not be assigned.
void __TBB_EXPORTED_METHOD change_group(task_group_context &ctx)
Moves this task from its current group into another one.
affinity_id affinity() const
Current affinity of this task.
version_traits_word_layout
#define __TBB_TASK_BASE_ACCESS
intptr_t isolation_tag
A tag for task isolation.
task * parent() const
task on whose behalf this task is working, or NULL if this is a root.
static void __TBB_EXPORTED_FUNC destroy(task &victim)
Destroy a task.
void call_itt_notify(notify_type, void *)
friend class internal::allocate_root_proxy
void increment_ref_count()
Atomically increment reference count.
uintptr_t my_version_and_traits
Version for run-time checks and behavioral traits of the context.
void recycle_as_continuation()
Change this to be a continuation of its former self.
uintptr_t _my_kind_aligner
internal::generic_scheduler * my_owner
Scheduler instance that registered this context in its thread specific list.
const isolation_tag no_isolation
task to be recycled as continuation
void set_affinity(affinity_id id)
Set affinity for this task.
void __TBB_EXPORTED_METHOD capture_fp_settings()
Captures the current FPU control settings to the context.
static void __TBB_EXPORTED_FUNC free(task &)
static const kind_type binding_completed
void __TBB_EXPORTED_METHOD free(task &) const
task_group_context * my_parent
Pointer to the context of the parent cancellation group. NULL for isolated contexts.
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 int
__itt_caller itt_caller
Used to set and maintain stack stitching point for Intel Performance Tools.
friend class internal::allocate_child_proxy
virtual void __TBB_EXPORTED_METHOD note_affinity(affinity_id id)
Invoked by scheduler to notify task that it ran on unexpected thread.
task is in ready pool, or is going to be put there, or was just taken off.
void const char const char int ITT_FORMAT __itt_group_sync p
struct ___itt_caller * __itt_caller
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 id
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
int add_ref_count(int count)
Atomically adds to reference count and returns its new value.
int space[sizeof(internal::uint64_t)/sizeof(int)]
task_group_context * context
Shared context that is used to communicate asynchronous state changes.
void __TBB_EXPORTED_METHOD internal_set_ref_count(int count)
Set reference count.
static const kind_type binding_required
friend class internal::allocate_root_proxy
task is running, and will be destroyed after method execute() completes.
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed.
const size_t NFS_MaxLineSize
Compile-time constant that is upper bound on cache line/sector size.
allocate_additional_child_of_proxy(task &parent_)
version_tag_v3 version_tag
function_task(const F &f)
friend class internal::allocate_additional_child_of_proxy
void recycle_as_safe_continuation()
Recommended to use, safe variant of recycle_as_continuation.
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 size
void __TBB_EXPORTED_METHOD register_pending_exception()
Records the pending exception, and cancels the task group.
void clear()
Clear the list.
friend class internal::allocate_root_with_context_proxy
int ref_count() const
The internal reference count.