Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::interface9::internal::do_task_iter< Iterator, Body, Item > Class Template Reference

For internal use only. More...

#include <parallel_do.h>

Inheritance diagram for tbb::interface9::internal::do_task_iter< Iterator, Body, Item >:
Collaboration diagram for tbb::interface9::internal::do_task_iter< Iterator, Body, Item >:

Public Member Functions

 do_task_iter (Iterator first, Iterator last, feeder_type &feeder)
 
- Public Member Functions inherited from tbb::task
virtual ~task ()
 Destructor. 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...
 

Private Types

typedef parallel_do_feeder_impl< Body, Item > feeder_type
 

Private Member Functions

taskexecute () __TBB_override
 Should be overridden by derived classes. More...
 
taskrun (void *)
 
taskrun_for_input_iterator ()
 
taskrun (std::forward_iterator_tag *)
 
taskrun_for_forward_iterator ()
 
taskrun (std::random_access_iterator_tag *)
 
taskrun_for_random_access_iterator ()
 

Private Attributes

Iterator my_first
 
Iterator my_last
 
feeder_typemy_feeder
 

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...
 
- 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...
 
- Protected Member Functions inherited from tbb::task
 task ()
 Default constructor. More...
 

Detailed Description

template<typename Iterator, typename Body, typename Item>
class tbb::interface9::internal::do_task_iter< Iterator, Body, Item >

For internal use only.

Gets block of iterations and packages them into a do_group_task.

Definition at line 298 of file parallel_do.h.

Member Typedef Documentation

◆ feeder_type

template<typename Iterator , typename Body , typename Item >
typedef parallel_do_feeder_impl<Body, Item> tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::feeder_type
private

Definition at line 300 of file parallel_do.h.

Constructor & Destructor Documentation

◆ do_task_iter()

template<typename Iterator , typename Body , typename Item >
tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::do_task_iter ( Iterator  first,
Iterator  last,
feeder_type feeder 
)
inline

Definition at line 303 of file parallel_do.h.

303  :
304  my_first(first), my_last(last), my_feeder(feeder)
305  {}
auto last(Container &c) -> decltype(begin(c))
auto first(Container &c) -> decltype(begin(c))

Referenced by tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run_for_random_access_iterator().

Here is the caller graph for this function:

Member Function Documentation

◆ execute()

template<typename Iterator , typename Body , typename Item >
task* tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::execute ( )
inlineprivatevirtual

Should be overridden by derived classes.

Implements tbb::task.

Definition at line 322 of file parallel_do.h.

323  {
324  typedef typename std::iterator_traits<Iterator>::iterator_category iterator_tag;
325  return run( (iterator_tag*)NULL );
326  }

References tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run().

Here is the call graph for this function:

◆ run() [1/3]

template<typename Iterator , typename Body , typename Item >
task* tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run ( void )
inlineprivate

This is the most restricted variant that operates on input iterators or iterators with unknown tags (tags not derived from the standard ones).

Definition at line 330 of file parallel_do.h.

References tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run_for_input_iterator().

Referenced by tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::execute().

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

◆ run() [2/3]

template<typename Iterator , typename Body , typename Item >
task* tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run ( std::forward_iterator_tag *  )
inlineprivate

Definition at line 356 of file parallel_do.h.

References tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run_for_forward_iterator().

Here is the call graph for this function:

◆ run() [3/3]

template<typename Iterator , typename Body , typename Item >
task* tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run ( std::random_access_iterator_tag *  )
inlineprivate

Definition at line 374 of file parallel_do.h.

References tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run_for_random_access_iterator().

Here is the call graph for this function:

◆ run_for_forward_iterator()

template<typename Iterator , typename Body , typename Item >
task* tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run_for_forward_iterator ( )
inlineprivate

Definition at line 358 of file parallel_do.h.

358  {
359  typedef do_group_task_forward<Iterator, Body, Item> block_type;
360 
361  Iterator first = my_first;
362  size_t k=0;
363  while( !(my_first==my_last) ) {
364  ++my_first;
365  if( ++k==block_type::max_arg_size ) {
366  if ( !(my_first==my_last) )
368  break;
369  }
370  }
371  return k==0 ? NULL : new( allocate_additional_child_of(*my_feeder.my_barrier) ) block_type(first, k, my_feeder);
372  }
void recycle_to_reexecute()
Schedule this for reexecution after current execute() returns.
Definition: task.h:741
auto first(Container &c) -> decltype(begin(c))

References tbb::internal::first(), tbb::interface9::internal::parallel_do_feeder_impl< Body, Item >::my_barrier, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_feeder, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_first, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_last, and tbb::task::recycle_to_reexecute().

Referenced by tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run().

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

◆ run_for_input_iterator()

template<typename Iterator , typename Body , typename Item >
task* tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run_for_input_iterator ( )
inlineprivate

Definition at line 332 of file parallel_do.h.

332  {
333  typedef do_group_task_input<Body, Item> block_type;
334 
335  block_type& t = *new( allocate_additional_child_of(*my_feeder.my_barrier) ) block_type(my_feeder);
336  size_t k=0;
337  while( !(my_first == my_last) ) {
338  // Move semantics are automatically used when supported by the iterator
339  new (t.my_arg.begin() + k) Item(*my_first);
340  ++my_first;
341  if( ++k==block_type::max_arg_size ) {
342  if ( !(my_first == my_last) )
344  break;
345  }
346  }
347  if( k==0 ) {
348  destroy(t);
349  return NULL;
350  } else {
351  t.my_size = k;
352  return &t;
353  }
354  }
void recycle_to_reexecute()
Schedule this for reexecution after current execute() returns.
Definition: task.h:741

References tbb::interface9::internal::parallel_do_feeder_impl< Body, Item >::my_barrier, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_feeder, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_first, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_last, and tbb::task::recycle_to_reexecute().

Referenced by tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run().

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

◆ run_for_random_access_iterator()

template<typename Iterator , typename Body , typename Item >
task* tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run_for_random_access_iterator ( )
inlineprivate

Definition at line 376 of file parallel_do.h.

376  {
377  typedef do_group_task_forward<Iterator, Body, Item> block_type;
378  typedef do_iteration_task_iter<Iterator, Body, Item> iteration_type;
379 
380  size_t k = static_cast<size_t>(my_last-my_first);
381  if( k > block_type::max_arg_size ) {
382  Iterator middle = my_first + k/2;
383 
384  empty_task& c = *new( allocate_continuation() ) empty_task;
385  do_task_iter& b = *new( c.allocate_child() ) do_task_iter(middle, my_last, my_feeder);
387 
388  my_last = middle;
389  c.set_ref_count(2);
390  c.spawn(b);
391  return this;
392  }else if( k != 0 ) {
393  task_list list;
394  task* t;
395  size_t k1=0;
396  for(;;) {
397  t = new( allocate_child() ) iteration_type(my_first, my_feeder);
398  ++my_first;
399  if( ++k1==k ) break;
400  list.push_back(*t);
401  }
402  set_ref_count(int(k+1));
403  spawn(list);
405  }
406  return NULL;
407  }
void spawn_and_wait_for_all(task &child)
Similar to spawn followed by wait_for_all, but more efficient.
Definition: task.h:800
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
Definition: task.h:681
friend class task_list
Definition: task.h:990
task()
Default constructor.
Definition: task.h:625
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
Definition: task.h:676
void recycle_as_child_of(task &new_parent)
Change this to be a child of new_parent.
Definition: task.h:725
void set_ref_count(int count)
Set reference count.
Definition: task.h:761
do_task_iter(Iterator first, Iterator last, feeder_type &feeder)
Definition: parallel_do.h:303

References tbb::task::allocate_child(), tbb::task::allocate_continuation(), tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::do_task_iter(), tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_feeder, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_first, tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::my_last, tbb::task_list::push_back(), tbb::task::recycle_as_child_of(), tbb::task::set_ref_count(), and tbb::task::spawn_and_wait_for_all().

Referenced by tbb::interface9::internal::do_task_iter< Iterator, Body, Item >::run().

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

Member Data Documentation

◆ my_feeder

◆ my_first

◆ my_last


The documentation for this class 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.