tbb::internal::task_group_base Class Reference

`#include <task_group.h>`

Inheritance diagram for tbb::internal::task_group_base:
Collaboration diagram for tbb::internal::task_group_base:

## Classes

class | ref_count_guard

## Public Member Functions

| task_group_base (uintptr_t traits=0)
| ~task_group_base () __TBB_NOEXCEPT(false)
template<typename F >
void | run (task_handle< F > &h)
task_group_status | wait ()
bool | is_canceling ()
void | cancel ()

## Protected Member Functions

template<typename F >
task_group_status | internal_run_and_wait (F &f)
template<typename Task , typename F >
task * | prepare_task (__TBB_FORWARDING_REF(F) f)

## Protected Attributes

empty_task * | my_root
task_group_context | my_context

## Additional Inherited Members

Private Member Functions inherited from tbb::internal::no_copy
| no_copy (const no_copy &)=delete
| no_copy ()=default

## Detailed Description

Definition at line 92 of file task_group.h.

## Constructor & Destructor Documentation

## task_group_base()

tbb::internal::task_group_base::task_group_base | ( | uintptr_t | traits = `0` | ) |

inline

Definition at line 128 of file task_group.h.

: my_context(task_group_context::bound, task_group_context::default_traits | traits)
{
my_root = new( task::allocate_root(my_context) ) empty_task;
my_root->set_ref_count(1);
}
tbb::task_group_context::default_traits
@ default_traits
Definition: task.h:391
tbb::task_group_context::bound
@ bound
Definition: task.h:379
tbb::task::allocate_root
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
Definition: task.h:663
tbb::task::set_ref_count
void set_ref_count(int count)
Set reference count.
Definition: task.h:761
tbb::internal::task_group_base::my_root
empty_task * my_root
Definition: task_group.h:104
tbb::internal::task_group_base::my_context
task_group_context my_context
Definition: task_group.h:105

References tbb::task::allocate_root(), my_context, my_root, and tbb::task::set_ref_count().

Here is the call graph for this function:

## ~task_group_base()

tbb::internal::task_group_base::~task_group_base | ( |  | ) |

inline

Definition at line 135 of file task_group.h.

{
if( my_root->ref_count() > 1 ) {
#if __TBB_CPP17_UNCAUGHT_EXCEPTIONS_PRESENT
bool stack_unwinding_in_progress = std::uncaught_exceptions() > 0;
#else
bool stack_unwinding_in_progress = std::uncaught_exception();
#endif
// Always attempt to do proper cleanup to avoid inevitable memory corruption
// in case of missing wait (for the sake of better testability & debuggability)
if ( !is_canceling() )
cancel();
__TBB_TRY {
my_root->wait_for_all();
} __TBB_CATCH (...) {
task::destroy(*my_root);
__TBB_RETHROW();
}
task::destroy(*my_root);
if ( !stack_unwinding_in_progress )
internal::throw_exception( internal::eid_missing_wait );
}
else {
task::destroy(*my_root);
}
}
__TBB_CATCH
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
__TBB_TRY
#define __TBB_TRY
Definition: tbb_stddef.h:283
__TBB_RETHROW
#define __TBB_RETHROW()
Definition: tbb_stddef.h:286
tbb::internal::throw_exception
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
Definition: tbb_exception.h:105
tbb::internal::eid_missing_wait
@ eid_missing_wait
Definition: tbb_exception.h:74
tbb::task::ref_count
int ref_count() const
The internal reference count.
Definition: task.h:915
tbb::task::wait_for_all
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
Definition: task.h:819
tbb::internal::task_group_base::cancel
void cancel()
Definition: task_group.h:185
tbb::internal::task_group_base::is_canceling
bool is_canceling()
Definition: task_group.h:181

References __TBB_CATCH, __TBB_RETHROW, __TBB_TRY, cancel(), tbb::internal::eid_missing_wait, is_canceling(), my_root, tbb::task::ref_count(), tbb::internal::throw_exception(), and tbb::task::wait_for_all().

Here is the call graph for this function:

## Member Function Documentation

## cancel()

void tbb::internal::task_group_base::cancel | ( |  | ) |

inline

Definition at line 185 of file task_group.h.

{
my_context.cancel_group_execution();
}
tbb::task_group_context::cancel_group_execution
bool __TBB_EXPORTED_METHOD cancel_group_execution()
Initiates cancellation of all tasks in this cancellation group and its subordinate groups.

References tbb::task_group_context::cancel_group_execution(), and my_context.

Referenced by ~task_group_base().

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

## internal_run_and_wait()

template<typename F >

task_group_status tbb::internal::task_group_base::internal_run_and_wait | ( | F & | f | ) |

inline protected

Definition at line 108 of file task_group.h.

{
__TBB_TRY {
if ( !my_context.is_group_execution_cancelled() ) {
// We need to increase the reference count of the root task to notify waiters that
// this task group has some work in progress.
ref_count_guard guard(*my_root);
f();
}
} __TBB_CATCH( ... ) {
my_context.register_pending_exception();
}
return wait();
}
tbb::task_group_context::is_group_execution_cancelled
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
tbb::task_group_context::register_pending_exception
void __TBB_EXPORTED_METHOD register_pending_exception()
Records the pending exception, and cancels the task group.
tbb::internal::task_group_base::wait
task_group_status wait()
Definition: task_group.h:166

References __TBB_CATCH, __TBB_TRY, tbb::task_group_context::is_group_execution_cancelled(), my_context, my_root, tbb::task_group_context::register_pending_exception(), and wait().

Here is the call graph for this function:

## is_canceling()

bool tbb::internal::task_group_base::is_canceling | ( |  | ) |

inline

Definition at line 181 of file task_group.h.

{
return my_context.is_group_execution_cancelled();
}

References tbb::task_group_context::is_group_execution_cancelled(), and my_context.

Referenced by ~task_group_base().

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

## prepare_task()

template<typename Task , typename F >

task* tbb::internal::task_group_base::prepare_task | ( | __TBB_FORWARDING_REF(F) | f | ) |

inline protected

Definition at line 123 of file task_group.h.

{
return new( task::allocate_additional_child_of(*my_root) ) Task( internal::forward<F>(f) );
}

References my_root.

Referenced by tbb::task_group::run(), and run().

Here is the caller graph for this function:

## run()

template<typename F >

void tbb::internal::task_group_base::run | ( | task_handle< F > & | h | ) |

inline

Definition at line 162 of file task_group.h.

{
task::spawn( *prepare_task< internal::task_handle_task<F> >(h) );
}
h
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 h
Definition: ittnotify_static.h:159
tbb::internal::task_group_base::prepare_task
task * prepare_task(__TBB_FORWARDING_REF(F) f)
Definition: task_group.h:123

References h, and prepare_task().

Here is the call graph for this function:

## wait()

task_group_status tbb::internal::task_group_base::wait | ( |  | ) |

inline

Definition at line 166 of file task_group.h.

{
__TBB_TRY {
my_root->wait_for_all();
} __TBB_CATCH( ... ) {
my_context.reset();
__TBB_RETHROW();
}
if ( my_context.is_group_execution_cancelled() ) {
// TODO: the reset method is not thread-safe. Ensure the correct behavior.
my_context.reset();
return canceled;
}
return complete;
}
tbb::complete
@ complete
Definition: task_group.h:75
tbb::canceled
@ canceled
Definition: task_group.h:76
tbb::task_group_context::reset
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed.

References __TBB_CATCH, __TBB_RETHROW, __TBB_TRY, tbb::canceled, tbb::complete, tbb::task_group_context::is_group_execution_cancelled(), my_context, my_root, tbb::task_group_context::reset(), and tbb::task::wait_for_all().

Referenced by internal_run_and_wait(), and tbb::structured_task_group::wait().

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

## Member Data Documentation

## my_context

task_group_context tbb::internal::task_group_base::my_context

protected

Definition at line 105 of file task_group.h.

Referenced by cancel(), internal_run_and_wait(), is_canceling(), task_group_base(), and wait().

## my_root

empty_task* tbb::internal::task_group_base::my_root

protected

Definition at line 104 of file task_group.h.

Referenced by internal_run_and_wait(), prepare_task(), task_group_base(), wait(), and ~task_group_base().

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

- task_group.h

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.