tbb::internal::finish_scan< Range, Body > Class Template Reference
Algorithms

Combine partial results. More...

`#include <parallel_scan.h>`

Inheritance diagram for tbb::internal::finish_scan< Range, Body >:
Collaboration diagram for tbb::internal::finish_scan< Range, Body >:

## Public Member Functions

task * | execute () __TBB_override
| Should be overridden by derived classes. More...
| finish_scan (sum_node_type *&return_slot_, final_sum_type **sum_, sum_node_type &result_)
Public Member Functions inherited from tbb::task
virtual | ~task ()
| Destructor. More...
internal::allocate_continuation_proxy & | allocate_continuation ()
| Returns proxy for overloaded new that allocates a continuation task of *this. More...
internal::allocate_child_proxy & | allocate_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...
task * | parent () 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_context * | context ()
| This method is deprecated and will be removed in the future. More...
task_group_context * | group ()
| 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...

## Public Attributes

final_sum_type * | my_right_zombie
sum_node_type & | my_result

## Private Types

typedef sum_node< Range, Body > | sum_node_type
typedef final_sum< Range, Body > | final_sum_type

## Private Attributes

final_sum_type **const | my_sum
sum_node_type *& | my_return_slot

## 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 __TBB_DEPRECATED void | enqueue (task &t, priority_t p)
| Enqueue task for starvation-resistant execution on the specified priority level. More...
static __TBB_DEPRECATED 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 Range, typename Body>
class tbb::internal::finish_scan< Range, Body >

Combine partial results.

Definition at line 145 of file parallel_scan.h.

## Member Typedef Documentation

## final_sum_type

template<typename Range , typename Body >

typedef final_sum<Range,Body> tbb::internal::finish_scan< Range, Body >::final_sum_type

private

Definition at line 147 of file parallel_scan.h.

## sum_node_type

template<typename Range , typename Body >

typedef sum_node<Range,Body> tbb::internal::finish_scan< Range, Body >::sum_node_type

private

Definition at line 146 of file parallel_scan.h.

## Constructor & Destructor Documentation

## finish_scan()

template<typename Range , typename Body >

tbb::internal::finish_scan< Range, Body >::finish_scan | ( | sum_node_type *& | return_slot_,
|  | final_sum_type ** | sum_,
|  | sum_node_type & | result_
| ) |  |

inline

Definition at line 173 of file parallel_scan.h.

:
my_sum(sum_),
my_return_slot(return_slot_),
my_right_zombie(NULL),
my_result(result_)
{
__TBB_ASSERT( !my_return_slot, NULL );
}

References __TBB_ASSERT, and tbb::internal::finish_scan< Range, Body >::my_return_slot.

## Member Function Documentation

## execute()

template<typename Range , typename Body >

task* tbb::internal::finish_scan< Range, Body >::execute | ( |  | ) |

inline virtual

Should be overridden by derived classes.

Implements tbb::task.

Definition at line 154 of file parallel_scan.h.

{
__TBB_ASSERT( my_result.ref_count()==(my_result.my_left!=NULL)+(my_result.my_right!=NULL), NULL );
if( my_result.my_left )
my_result.my_left_is_final = false;
if( my_right_zombie && my_sum )
((*my_sum)->my_body).reverse_join(my_result.my_left_sum->my_body);
__TBB_ASSERT( !my_return_slot, NULL );
if( my_right_zombie || my_result.my_right ) {
my_return_slot = &my_result;
} else {
destroy( my_result );
}
if( my_right_zombie && !my_sum && !my_result.my_right ) {
destroy(*my_right_zombie);
my_right_zombie = NULL;
}
return NULL;
}

References __TBB_ASSERT, tbb::internal::final_sum< Range, Body >::my_body, tbb::internal::sum_node< Range, Body >::my_left, tbb::internal::sum_node< Range, Body >::my_left_is_final, tbb::internal::sum_node< Range, Body >::my_left_sum, tbb::internal::finish_scan< Range, Body >::my_result, tbb::internal::finish_scan< Range, Body >::my_return_slot, tbb::internal::sum_node< Range, Body >::my_right, tbb::internal::finish_scan< Range, Body >::my_right_zombie, tbb::internal::finish_scan< Range, Body >::my_sum, and tbb::task::ref_count().

Here is the call graph for this function:

## Member Data Documentation

## my_result

template<typename Range , typename Body >

sum_node_type& tbb::internal::finish_scan< Range, Body >::my_result

Definition at line 152 of file parallel_scan.h.

Referenced by tbb::internal::finish_scan< Range, Body >::execute().

## my_return_slot

template<typename Range , typename Body >

sum_node_type*& tbb::internal::finish_scan< Range, Body >::my_return_slot

private

Definition at line 149 of file parallel_scan.h.

Referenced by tbb::internal::finish_scan< Range, Body >::execute(), and tbb::internal::finish_scan< Range, Body >::finish_scan().

## my_right_zombie

template<typename Range , typename Body >

final_sum_type* tbb::internal::finish_scan< Range, Body >::my_right_zombie

Definition at line 151 of file parallel_scan.h.

Referenced by tbb::internal::finish_scan< Range, Body >::execute().

## my_sum

template<typename Range , typename Body >

final_sum_type** const tbb::internal::finish_scan< Range, Body >::my_sum

private

Definition at line 148 of file parallel_scan.h.

Referenced by tbb::internal::finish_scan< Range, Body >::execute().

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

- parallel_scan.h

__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::sum_node::my_left_is_final
bool my_left_is_final
Definition: parallel_scan.h:92
tbb::internal::finish_scan::my_right_zombie
final_sum_type * my_right_zombie
Definition: parallel_scan.h:151
tbb::internal::finish_scan::my_sum
final_sum_type **const my_sum
Definition: parallel_scan.h:148
tbb::internal::sum_node::my_left
sum_node * my_left
Definition: parallel_scan.h:90
tbb::internal::finish_scan::my_result
sum_node_type & my_result
Definition: parallel_scan.h:152
tbb::task::ref_count
int ref_count() const
The internal reference count.
Definition: task.h:904
tbb::internal::finish_scan::my_return_slot
sum_node_type *& my_return_slot
Definition: parallel_scan.h:149
tbb::internal::sum_node::my_right
sum_node * my_right
Definition: parallel_scan.h:91
tbb::internal::final_sum::my_body
Body my_body
Definition: parallel_scan.h:52
tbb::internal::sum_node::my_left_sum
final_sum_type * my_left_sum
Definition: parallel_scan.h:89

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.