tbb::internal::spawner< N, function1, function2, function3 > Class Template Reference

`#include <parallel_invoke.h>`

Inheritance diagram for tbb::internal::spawner< N, function1, function2, function3 >:
Collaboration diagram for tbb::internal::spawner< N, function1, function2, function3 >:

## Public Member Functions

| spawner (const function1 &_func1, const function2 &_func2, const function3 &_func3)
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...

## Private Member Functions

task * | execute () __TBB_override
| Should be overridden by derived classes. More...

## Private Attributes

const function1 & | my_func1
const function2 & | my_func2
const function3 & | my_func3
bool | is_recycled

## 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<size_t N, typename function1, typename function2, typename function3>
class tbb::internal::spawner< N, function1, function2, function3 >

Definition at line 57 of file parallel_invoke.h.

## Constructor & Destructor Documentation

## spawner()

template<size_t N, typename function1, typename function2, typename function3>

tbb::internal::spawner< N, function1, function2, function3 >::spawner | ( | const function1 & | _func1,
|  | const function2 & | _func2,
|  | const function3 & | _func3
| ) |  |

inline

Definition at line 87 of file parallel_invoke.h.

: my_func1(_func1), my_func2(_func2), my_func3(_func3), is_recycled(false) {}

## Member Function Documentation

## execute()

template<size_t N, typename function1, typename function2, typename function3>

task* tbb::internal::spawner< N, function1, function2, function3 >::execute | ( |  | ) |

inline private virtual

Should be overridden by derived classes.

Implements tbb::task.

Definition at line 64 of file parallel_invoke.h.

{
if(is_recycled){
return NULL;
}else{
__TBB_ASSERT(N==2 || N==3, "Number of arguments passed to spawner is wrong");
set_ref_count(N);
recycle_as_safe_continuation();
internal::function_invoker<function2>* invoker2 = new (allocate_child()) internal::function_invoker<function2>(my_func2);
__TBB_ASSERT(invoker2, "Child task allocation failed");
spawn(*invoker2);
size_t n = N; // To prevent compiler warnings
if (n>2) {
internal::function_invoker<function3>* invoker3 = new (allocate_child()) internal::function_invoker<function3>(my_func3);
__TBB_ASSERT(invoker3, "Child task allocation failed");
spawn(*invoker3);
}
my_func1();
is_recycled = true;
return NULL;
}
} // execute

References __TBB_ASSERT, tbb::task::allocate_child(), tbb::internal::spawner< N, function1, function2, function3 >::is_recycled, tbb::internal::spawner< N, function1, function2, function3 >::my_func1, tbb::internal::spawner< N, function1, function2, function3 >::my_func2, tbb::internal::spawner< N, function1, function2, function3 >::my_func3, tbb::task::recycle_as_safe_continuation(), and tbb::task::set_ref_count().

Here is the call graph for this function:

## Member Data Documentation

## is_recycled

template<size_t N, typename function1, typename function2, typename function3>

bool tbb::internal::spawner< N, function1, function2, function3 >::is_recycled

private

Definition at line 62 of file parallel_invoke.h.

Referenced by tbb::internal::spawner< N, function1, function2, function3 >::execute().

## my_func1

template<size_t N, typename function1, typename function2, typename function3>

const function1& tbb::internal::spawner< N, function1, function2, function3 >::my_func1

private

Definition at line 59 of file parallel_invoke.h.

Referenced by tbb::internal::spawner< N, function1, function2, function3 >::execute().

## my_func2

template<size_t N, typename function1, typename function2, typename function3>

const function2& tbb::internal::spawner< N, function1, function2, function3 >::my_func2

private

Definition at line 60 of file parallel_invoke.h.

Referenced by tbb::internal::spawner< N, function1, function2, function3 >::execute().

## my_func3

template<size_t N, typename function1, typename function2, typename function3>

const function3& tbb::internal::spawner< N, function1, function2, function3 >::my_func3

private

Definition at line 61 of file parallel_invoke.h.

Referenced by tbb::internal::spawner< N, function1, function2, function3 >::execute().

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

- parallel_invoke.h

tbb::task::set_ref_count
void set_ref_count(int count)
Set reference count.
Definition: task.h:750
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::spawner::my_func2
const function2 & my_func2
Definition: parallel_invoke.h:60
tbb::task::allocate_child
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
Definition: task.h:670
tbb::task::recycle_as_safe_continuation
void recycle_as_safe_continuation()
Recommended to use, safe variant of recycle_as_continuation.
Definition: task.h:708
tbb::internal::spawner::my_func3
const function3 & my_func3
Definition: parallel_invoke.h:61
tbb::internal::spawner::is_recycled
bool is_recycled
Definition: parallel_invoke.h:62
tbb::internal::spawner::my_func1
const function1 & my_func1
Definition: parallel_invoke.h:59

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.