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

#include <mailbox.h>

Inheritance diagram for tbb::internal::task_proxy:
Collaboration diagram for tbb::internal::task_proxy:

Public Member Functions

template<intptr_t from_bit>
taskextract_task ()
 Returns a pointer to the encapsulated task or NULL, and frees proxy if necessary. More...
 
- Public Member Functions inherited from tbb::task
virtual ~task ()
 Destructor. More...
 
virtual taskexecute ()=0
 Should be overridden by derived classes. More...
 
internal::allocate_continuation_proxyallocate_continuation ()
 Returns proxy for overloaded new that allocates a continuation task of *this. More...
 
internal::allocate_child_proxyallocate_child ()
 Returns proxy for overloaded new that allocates a child task of *this. More...
 
void recycle_as_continuation ()
 Change this to be a continuation of its former self. More...
 
void recycle_as_safe_continuation ()
 Recommended to use, safe variant of recycle_as_continuation. More...
 
void recycle_as_child_of (task &new_parent)
 Change this to be a child of new_parent. More...
 
void recycle_to_reexecute ()
 Schedule this for reexecution after current execute() returns. More...
 
void set_ref_count (int count)
 Set reference count. More...
 
void increment_ref_count ()
 Atomically increment reference count. More...
 
int add_ref_count (int count)
 Atomically adds to reference count and returns its new value. More...
 
int decrement_ref_count ()
 Atomically decrement reference count and returns its new value. More...
 
void spawn_and_wait_for_all (task &child)
 Similar to spawn followed by wait_for_all, but more efficient. More...
 
void __TBB_EXPORTED_METHOD spawn_and_wait_for_all (task_list &list)
 Similar to spawn followed by wait_for_all, but more efficient. More...
 
void wait_for_all ()
 Wait for reference count to become one, and set reference count to zero. More...
 
taskparent () const
 task on whose behalf this task is working, or NULL if this is a root. More...
 
void set_parent (task *p)
 sets parent task pointer to specified value More...
 
task_group_contextcontext ()
 This method is deprecated and will be removed in the future. More...
 
task_group_contextgroup ()
 Pointer to the task group descriptor. More...
 
bool is_stolen_task () const
 True if task was stolen from the task pool of another thread. More...
 
bool is_enqueued_task () const
 True if the task was enqueued. More...
 
state_type state () const
 Current execution state. More...
 
int ref_count () const
 The internal reference count. More...
 
bool __TBB_EXPORTED_METHOD is_owned_by_current_thread () const
 Obsolete, and only retained for the sake of backward compatibility. Always returns true. More...
 
void set_affinity (affinity_id id)
 Set affinity for this task. More...
 
affinity_id affinity () const
 Current affinity of this task. More...
 
virtual void __TBB_EXPORTED_METHOD note_affinity (affinity_id id)
 Invoked by scheduler to notify task that it ran on unexpected thread. More...
 
void __TBB_EXPORTED_METHOD change_group (task_group_context &ctx)
 Moves this task from its current group into another one. More...
 
bool cancel_group_execution ()
 Initiates cancellation of all tasks in this cancellation group and its subordinate groups. More...
 
bool is_cancelled () const
 Returns true if the context has received cancellation request. More...
 
__TBB_DEPRECATED void set_group_priority (priority_t p)
 Changes priority of the task group this task belongs to. More...
 
__TBB_DEPRECATED priority_t group_priority () const
 Retrieves current priority of the task group this task belongs to. More...
 

Static Public Member Functions

static bool is_shared (intptr_t tat)
 True if the proxy is stored both in its sender's pool and in the destination mailbox. More...
 
static tasktask_ptr (intptr_t tat)
 Returns a pointer to the encapsulated task or NULL. More...
 
- Static Public Member Functions inherited from tbb::task
static internal::allocate_root_proxy allocate_root ()
 Returns proxy for overloaded new that allocates a root task. More...
 
static internal::allocate_root_with_context_proxy allocate_root (task_group_context &ctx)
 Returns proxy for overloaded new that allocates a root task associated with user supplied context. More...
 
static void spawn_root_and_wait (task &root)
 Spawn task allocated by allocate_root, wait for it to complete, and deallocate it. More...
 
static void spawn_root_and_wait (task_list &root_list)
 Spawn root tasks on list and wait for all of them to finish. More...
 
static void enqueue (task &t)
 Enqueue task for starvation-resistant execution. More...
 
static void enqueue (task &t, priority_t p)
 Enqueue task for starvation-resistant execution on the specified priority level. More...
 
static void enqueue (task &t, task_arena &arena, priority_t p=priority_t(0))
 Enqueue task in task_arena. More...
 
static task &__TBB_EXPORTED_FUNC self ()
 The innermost task being executed or destroyed by the current thread at the moment. More...
 

Public Attributes

intptr_t task_and_tag
 
task_proxy *__TBB_atomic next_in_mailbox
 Pointer to next task_proxy in a mailbox. More...
 
mail_outboxoutbox
 Mailbox to which this was mailed. More...
 

Static Public Attributes

static const intptr_t pool_bit = 1<<0
 
static const intptr_t mailbox_bit = 1<<1
 
static const intptr_t location_mask = pool_bit | mailbox_bit
 

Additional Inherited Members

- Public Types inherited from tbb::task
enum  state_type {
  executing, reexecute, ready, allocated,
  freed, recycle
}
 Enumeration of task states that the scheduler considers. More...
 
typedef internal::affinity_id affinity_id
 An id as used for specifying affinity. More...
 
- Protected Member Functions inherited from tbb::task
 task ()
 Default constructor. More...
 

Detailed Description

Definition at line 29 of file mailbox.h.

Member Function Documentation

◆ extract_task()

template<intptr_t from_bit>
task* tbb::internal::task_proxy::extract_task ( )
inline

Returns a pointer to the encapsulated task or NULL, and frees proxy if necessary.

Definition at line 57 of file mailbox.h.

57  {
58  __TBB_ASSERT( prefix().extra_state == es_task_proxy, "Normal task misinterpreted as a proxy?" );
59  intptr_t tat = __TBB_load_with_acquire(task_and_tag);
60  __TBB_ASSERT( tat == from_bit || (is_shared(tat) && task_ptr(tat)),
61  "Proxy's tag cannot specify both locations if the proxy "
62  "was retrieved from one of its original locations" );
63  if ( tat != from_bit ) {
64  const intptr_t cleaner_bit = location_mask & ~from_bit;
65  // Attempt to transition the proxy to the "empty" state with
66  // cleaner_bit specifying entity responsible for its eventual freeing.
67  // Explicit cast to void* is to work around a seeming ICC 11.1 bug.
68  if ( as_atomic(task_and_tag).compare_and_swap(cleaner_bit, tat) == tat ) {
69  // Successfully grabbed the task, and left new owner with the job of freeing the proxy
70  return task_ptr(tat);
71  }
72  }
73  // Proxied task has already been claimed from another proxy location.
74  __TBB_ASSERT( task_and_tag == from_bit, "Empty proxy cannot contain non-zero task pointer" );
75  return NULL;
76  }
internal::task_prefix & prefix(internal::version_tag *=NULL) const
Get reference to corresponding task_prefix.
Definition: task.h:1002
static const intptr_t location_mask
Definition: mailbox.h:32
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
static task * task_ptr(intptr_t tat)
Returns a pointer to the encapsulated task or NULL.
Definition: mailbox.h:51
atomic< T > & as_atomic(T &t)
Definition: atomic.h:572
Tag for v3 task_proxy.
T __TBB_load_with_acquire(const volatile T &location)
Definition: tbb_machine.h:709
static bool is_shared(intptr_t tat)
True if the proxy is stored both in its sender's pool and in the destination mailbox.
Definition: mailbox.h:46

References __TBB_ASSERT, tbb::internal::__TBB_load_with_acquire(), tbb::internal::as_atomic(), tbb::internal::es_task_proxy, is_shared(), location_mask, tbb::task::prefix(), task_and_tag, and task_ptr().

Referenced by tbb::internal::generic_scheduler::get_task(), and tbb::internal::generic_scheduler::steal_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_shared()

static bool tbb::internal::task_proxy::is_shared ( intptr_t  tat)
inlinestatic

True if the proxy is stored both in its sender's pool and in the destination mailbox.

Definition at line 46 of file mailbox.h.

46  {
47  return (tat & location_mask) == location_mask;
48  }
static const intptr_t location_mask
Definition: mailbox.h:32

References location_mask.

Referenced by extract_task(), and tbb::internal::generic_scheduler::steal_task_from().

Here is the caller graph for this function:

◆ task_ptr()

static task* tbb::internal::task_proxy::task_ptr ( intptr_t  tat)
inlinestatic

Returns a pointer to the encapsulated task or NULL.

Definition at line 51 of file mailbox.h.

51  {
52  return (task*)(tat & ~location_mask);
53  }
task()
Default constructor.
Definition: task.h:625
static const intptr_t location_mask
Definition: mailbox.h:32

References location_mask.

Referenced by extract_task().

Here is the caller graph for this function:

Member Data Documentation

◆ location_mask

const intptr_t tbb::internal::task_proxy::location_mask = pool_bit | mailbox_bit
static

◆ mailbox_bit

const intptr_t tbb::internal::task_proxy::mailbox_bit = 1<<1
static

Definition at line 31 of file mailbox.h.

Referenced by tbb::internal::generic_scheduler::get_mailbox_task().

◆ next_in_mailbox

task_proxy* __TBB_atomic tbb::internal::task_proxy::next_in_mailbox

◆ outbox

mail_outbox* tbb::internal::task_proxy::outbox

Mailbox to which this was mailed.

Definition at line 43 of file mailbox.h.

Referenced by tbb::internal::generic_scheduler::prepare_for_spawning(), and tbb::internal::generic_scheduler::steal_task_from().

◆ pool_bit

const intptr_t tbb::internal::task_proxy::pool_bit = 1<<0
static

◆ task_and_tag

intptr_t tbb::internal::task_proxy::task_and_tag

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

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.