19 #if !defined(__TBB_show_deprecation_message_task_H) && defined(__TBB_show_deprecated_header_message) 20 #define __TBB_show_deprecation_message_task_H 21 #pragma message("TBB Warning: tbb/task.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.") 24 #if defined(__TBB_show_deprecated_header_message) 25 #undef __TBB_show_deprecated_header_message 31 #define __TBB_task_H_include_area 45 class task_group_context;
49 #if _MSC_VER || (__GNUC__==3 && __GNUC_MINOR__<3) 50 #define __TBB_TASK_BASE_ACCESS public 52 #define __TBB_TASK_BASE_ACCESS private 72 namespace interface5 {
85 static void spawn(
task& t );
119 virtual void spawn_root_and_wait(
task& first,
task*& next ) = 0;
126 virtual void enqueue(
task& t,
void* reserved ) = 0;
133 #if __TBB_PREVIEW_RESUMABLE_TASKS 141 #if __TBB_TASK_ISOLATION 147 #if __TBB_TASK_GROUP_CONTEXT 182 #if __TBB_PREVIEW_CRITICAL_TASKS 213 #if __TBB_PREVIEW_CRITICAL_TASKS 218 #if __TBB_TASK_ISOLATION 219 isolation_tag isolation;
222 intptr_t reserved_space_for_task_isolation_tag;
225 #if __TBB_TASK_GROUP_CONTEXT 241 #if __TBB_TASK_PRIORITY || __TBB_PREVIEW_RESUMABLE_TASKS 249 #if __TBB_TASK_PRIORITY 255 #if __TBB_PREVIEW_RESUMABLE_TASKS 259 #if __TBB_TASK_PRIORITY || __TBB_PREVIEW_RESUMABLE_TASKS 306 #if __TBB_TASK_GROUP_CONTEXT 308 #if __TBB_TASK_PRIORITY 311 #if __TBB_PREVIEW_CRITICAL_TASKS 325 #if TBB_USE_CAPTURED_EXCEPTION 334 namespace interface7 {
class task_arena; }
362 friend class task_arena;
364 #if TBB_USE_CAPTURED_EXCEPTION 372 version_mask = 0xFFFF,
373 traits_mask = 0xFFFFul << traits_offset
383 exact_exception = 0x0001ul << traits_offset,
385 fp_settings = 0x0002ul << traits_offset,
387 concurrent_wait = 0x0004ul << traits_offset,
388 #if TBB_USE_CAPTURED_EXCEPTION 391 default_traits = exact_exception
397 may_have_children = 1,
457 #if __TBB_TASK_PRIORITY 458 intptr_t my_priority;
468 #if __TBB_TASK_PRIORITY 505 uintptr_t t = default_traits )
506 : my_kind(relation_with_parent)
507 , my_version_and_traits(3 | t)
516 , my_version_and_traits(3 | default_traits)
569 #if __TBB_TASK_PRIORITY 578 uintptr_t
traits()
const {
return my_version_and_traits & traits_mask; }
595 template <
typename T>
625 task() {prefix().extra_state=1;}
632 virtual task* execute() = 0;
648 #if __TBB_RECYCLE_TO_ENQUEUE 652 #if __TBB_PREVIEW_RESUMABLE_TASKS 667 #if __TBB_TASK_GROUP_CONTEXT 686 using task_base::allocate_additional_child_of;
688 #if __TBB_DEPRECATED_TASK_INTERFACE 696 using task_base::destroy;
712 __TBB_ASSERT( prefix().state==executing,
"execute not running?" );
713 prefix().state = allocated;
720 __TBB_ASSERT( prefix().state==executing,
"execute not running?" );
721 prefix().state = recycle;
727 __TBB_ASSERT( prefix().state==executing||prefix().state==allocated,
"execute not running, or already recycled" );
728 __TBB_ASSERT( prefix().ref_count==0,
"no child tasks allowed when recycled as a child" );
734 #if __TBB_TASK_GROUP_CONTEXT 742 __TBB_ASSERT( prefix().state==executing,
"execute not running, or already recycled" );
743 __TBB_ASSERT( prefix().ref_count==0,
"no child tasks allowed when recycled for reexecution" );
744 prefix().state = reexecute;
747 #if __TBB_RECYCLE_TO_ENQUEUE 750 void recycle_to_enqueue() {
751 __TBB_ASSERT( prefix().state==executing,
"execute not running, or already recycled" );
752 prefix().state = to_enqueue;
762 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 763 internal_set_ref_count(count);
765 prefix().ref_count =
count;
780 __TBB_ASSERT( k>=0,
"task's reference count underflowed" );
789 #if TBB_USE_THREADING_TOOLS||TBB_USE_ASSERT 790 return int(internal_decrement_ref_count());
797 using task_base::spawn;
801 prefix().owner->wait_for_all( *
this, &child );
815 static void spawn_root_and_wait(
task_list& root_list );
820 prefix().owner->wait_for_all( *
this, NULL );
824 #if __TBB_TASK_PRIORITY 840 #if __TBB_TASK_PRIORITY 843 #if __TBB_PREVIEW_CRITICAL_TASKS 855 #if __TBB_TASK_PRIORITY 858 inline static void enqueue(
task& t, task_arena& arena);
869 #if __TBB_TASK_GROUP_CONTEXT 875 #if __TBB_TASK_GROUP_CONTEXT 886 return (prefix().extra_state & 0x80)!=0;
892 return (prefix().extra_state & 0x10)!=0;
895 #if __TBB_PREVIEW_RESUMABLE_TASKS 896 typedef void* suspend_point;
900 template <
typename F>
901 static void suspend(F f);
904 static void resume(suspend_point tag);
917 #if __TBB_PREVIEW_RESUMABLE_TASKS 922 __TBB_ASSERT( ref_count_==
int(ref_count_),
"integer overflow error");
924 #if __TBB_PREVIEW_RESUMABLE_TASKS 925 return int(prefix().ref_count & ~internal::abandon_flag);
927 return int(prefix().ref_count);
946 affinity_id
affinity()
const {
return prefix().affinity;}
955 #if __TBB_TASK_GROUP_CONTEXT 974 bool is_cancelled ()
const {
return prefix().context->is_group_execution_cancelled(); }
976 bool is_cancelled ()
const {
return false; }
979 #if __TBB_TASK_PRIORITY 993 #if __TBB_TASK_GROUP_CONTEXT 1005 #if __TBB_PREVIEW_CRITICAL_TASKS 1011 #if __TBB_PREVIEW_CRITICAL_TASKS 1018 #if __TBB_PREVIEW_RESUMABLE_TASKS 1020 template <
typename F>
1021 static void suspend_callback(
void* user_callback, task::suspend_point tag) {
1023 F user_callback_copy = *
static_cast<F*
>(user_callback);
1024 user_callback_copy(tag);
1031 template <
typename F>
1032 inline void task::suspend(F f) {
1033 internal::internal_suspend((
void*)internal::suspend_callback<F>, &f);
1035 inline void task::resume(suspend_point tag) {
1036 internal::internal_resume(tag);
1050 template<
typename F>
1052 #if __TBB_ALLOW_MUTABLE_FUNCTORS 1064 #if __TBB_CPP11_RVALUE_REF_PRESENT 1110 __TBB_ASSERT( !empty(),
"attempt to pop item from empty task_list" );
1111 task* result =
first;
1113 if( !first ) next_ptr = &
first;
1130 t->prefix().owner->spawn( *t, *list.
next_ptr );
1137 t->prefix().owner->spawn_root_and_wait( *t, *root_list.
next_ptr );
1152 #if __TBB_TASK_GROUP_CONTEXT 1154 return &
p.allocate(bytes);
1158 p.free( *static_cast<tbb::task*>(task) );
1163 return &
p.allocate(bytes);
1167 p.free( *static_cast<tbb::task*>(task) );
1171 return &
p.allocate(bytes);
1175 p.free( *static_cast<tbb::task*>(task) );
1179 return &
p.allocate(bytes);
1183 p.free( *static_cast<tbb::task*>(task) );
1187 #undef __TBB_task_H_include_area Base class for types that should not be copied or assigned.
task object is freshly allocated or recycled.
void make_critical(task &t)
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
static void __TBB_EXPORTED_FUNC free(task &)
Exception container that preserves the exact copy of the original exception.
__itt_caller itt_caller
Used to set and maintain stack stitching point for Intel Performance Tools.
internal::context_list_node_t my_node
Used to form the thread specific list of contexts without additional memory allocation.
scheduler * origin
The scheduler that allocated the task, or NULL if the task is big.
Memory prefix to a task object.
context_list_node_t * my_prev
allocate_additional_child_of_proxy(task &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 id
uintptr_t my_state
Internal state (combination of state flags, currently only may_have_children).
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
function_task(const F &f)
static const int priority_critical
void set_parent(task *p)
sets parent task pointer to specified value
internal::task_prefix & prefix(internal::version_tag *=NULL) const
Get reference to corresponding task_prefix.
tbb::task * parent
The task whose reference count includes me.
int decrement_ref_count()
Atomically decrement reference count and returns its new value.
task * execute() __TBB_override
Should be overridden by derived classes.
tbb::task * next
"next" field for list of task
internal::generic_scheduler * my_owner
Scheduler instance that registered this context in its thread specific list.
void clear()
Clear the list.
#define __TBB_FetchAndIncrementWacquire(P)
void suppress_unused_warning(const T1 &)
Utility template function to prevent "unused" warnings by various compilers.
task &__TBB_EXPORTED_METHOD allocate(size_t size) const
allocate_root_with_context_proxy(task_group_context &ctx)
Base class for types that should not be assigned.
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
scheduler * owner
Obsolete. The scheduler that owns the task.
bool is_critical(task &t)
exception_container_type * my_exception
Pointer to the container storing exception being propagated across this task group.
uintptr_t _my_kind_aligner
static const int priority_stride_v4
Interface to be implemented by all exceptions TBB recognizes and propagates across the threads...
int ref_count() const
The internal reference count.
void recycle_to_reexecute()
Schedule this for reexecution after current execute() returns.
task_list()
Construct empty list.
state_type state() const
Current execution state.
task_group_context(internal::string_index name)
~task_list()
Destroys the list, but does not destroy the task objects.
task_group_context & my_context
tbb::task & task()
The task corresponding to this task_prefix.
task * parent() const
task on whose behalf this task is working, or NULL if this is a root.
unsigned char extra_state
Miscellaneous state that is not directly visible to users, stored as a byte for compactness.
void increment_ref_count()
Atomically increment reference count.
Base class for user-defined tasks.
#define __TBB_TASK_BASE_ACCESS
virtual ~task()
Destructor.
static void spawn(task &t)
Schedule task for execution when a worker becomes available.
task object is on free list, or is going to be put there, or was just taken off.
bool is_stolen_task() const
True if task was stolen from the task pool of another thread.
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_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
static void enqueue(task &t)
Enqueue task for starvation-resistant execution.
task()
Default constructor.
uintptr_t traits() const
Returns the context's trait.
bool empty() const
True if list is empty; false otherwise.
state_type
Enumeration of task states that the scheduler considers.
__TBB_atomic kind_type my_kind
Flavor of this context: bound or isolated.
#define __TBB_FetchAndDecrementWrelease(P)
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
const size_t NFS_MaxLineSize
Compile-time constant that is upper bound on cache line/sector size.
Class delimiting the scope of task scheduler activity.
void recycle_as_continuation()
Change this to be a continuation of its former self.
virtual void spawn_root_and_wait(task &first, task *&next)=0
For internal use only.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
internal::cpu_ctl_env_space my_cpu_ctl_env
Space for platform-specific FPU settings.
unsigned short affinity_id
An id as used for specifying affinity.
bool cancel_group_execution()
Initiates cancellation of all tasks in this cancellation group and its subordinate groups...
__TBB_atomic reference_count ref_count
Reference count used for synchronization.
task * next_offloaded
Pointer to the next offloaded lower priority task.
void move(tbb_thread &t1, tbb_thread &t2)
intptr_t reference_count
A reference count.
Used to form groups of tasks.
const isolation_tag no_isolation
internal::tbb_exception_ptr exception_container_type
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.
struct ___itt_caller * __itt_caller
static task &__TBB_EXPORTED_FUNC allocate(size_t size)
intptr_t isolation_tag
A tag for task isolation.
void call_itt_notify(notify_type, void *)
void spawn_and_wait_for_all(task &child)
Similar to spawn followed by wait_for_all, but more efficient.
void recycle_as_child_of(task &new_parent)
Change this to be a child of new_parent.
int depth
Obsolete. Used to be scheduling depth before TBB 2.2.
#define __TBB_EXPORTED_METHOD
uintptr_t my_cancellation_requested
Specifies whether cancellation was requested for this task group.
internal::affinity_id affinity_id
An id as used for specifying affinity.
virtual void spawn(task &first, task *&next)=0
For internal use only.
bool is_cancelled() const
Returns true if the context has received cancellation request.
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
void set_affinity(affinity_id id)
Set affinity for this task.
Work stealing task scheduler.
internal::string_index my_name
Description of algorithm for scheduler based instrumentation.
__TBB_DEPRECATED priority_t group_priority() const
Retrieves current priority of the task group this task belongs to.
uintptr_t my_version_and_traits
Version for run-time checks and behavioral traits of the context.
task_group_context * group()
Pointer to the task group descriptor.
void recycle_as_safe_continuation()
Recommended to use, safe variant of recycle_as_continuation.
affinity_id affinity() const
Current affinity of this task.
task_group_context * context()
This method is deprecated and will be removed in the future.
task_group_context * context
Shared context that is used to communicate asynchronous state changes.
virtual void enqueue(task &t, void *reserved)=0
For internal use only.
void set_ref_count(int count)
Set reference count.
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 * task
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
void const char const char int ITT_FORMAT __itt_group_sync p
task * self
No longer used, but retained for binary layout compatibility. Always NULL.
auto first(Container &c) -> decltype(begin(c))
unsigned char state
A task::state_type, stored as a byte for compactness.
#define __TBB_DEPRECATED_IN_VERBOSE_MODE
task that does nothing. Useful for synchronization.
void push_back(task &task)
Push task onto back of list.
task is running, and will be destroyed after method execute() completes.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
bool is_enqueued_task() const
True if the task was enqueued.
#define __TBB_EXPORTED_FUNC
task * execute() __TBB_override
Should be overridden by derived classes.
task is in ready pool, or is going to be put there, or was just taken off.
Base class for methods that became static in TBB 3.0.
task_group_context(kind_type relation_with_parent=bound, uintptr_t t=default_traits)
Default & binding constructor.
version_traits_word_layout
int add_ref_count(int count)
Atomically adds to reference count and returns its new value.
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
void __TBB_EXPORTED_METHOD free(task &) const