Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
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 >
taskprepare_task (__TBB_FORWARDING_REF(F) f)
 

Protected Attributes

empty_taskmy_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.

130  {
131  my_root = new( task::allocate_root(my_context) ) empty_task;
133  }
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
Definition: task.h:663
void set_ref_count(int count)
Set reference count.
Definition: task.h:761
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.

135  {
136  if( my_root->ref_count() > 1 ) {
137 #if __TBB_CPP17_UNCAUGHT_EXCEPTIONS_PRESENT
138  bool stack_unwinding_in_progress = std::uncaught_exceptions() > 0;
139 #else
140  bool stack_unwinding_in_progress = std::uncaught_exception();
141 #endif
142  // Always attempt to do proper cleanup to avoid inevitable memory corruption
143  // in case of missing wait (for the sake of better testability & debuggability)
144  if ( !is_canceling() )
145  cancel();
146  __TBB_TRY {
148  } __TBB_CATCH (...) {
149  task::destroy(*my_root);
150  __TBB_RETHROW();
151  }
152  task::destroy(*my_root);
153  if ( !stack_unwinding_in_progress )
155  }
156  else {
157  task::destroy(*my_root);
158  }
159  }
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
Definition: task.h:819
#define __TBB_RETHROW()
Definition: tbb_stddef.h:286
int ref_count() const
The internal reference count.
Definition: task.h:915
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
#define __TBB_TRY
Definition: tbb_stddef.h:283
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()

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.

185  {
187  }
bool __TBB_EXPORTED_METHOD cancel_group_execution()
Initiates cancellation of all tasks in this cancellation group and its subordinate groups.
task_group_context my_context
Definition: task_group.h:105

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)
inlineprotected

Definition at line 108 of file task_group.h.

108  {
109  __TBB_TRY {
111  // We need to increase the reference count of the root task to notify waiters that
112  // this task group has some work in progress.
113  ref_count_guard guard(*my_root);
114  f();
115  }
116  } __TBB_CATCH( ... ) {
118  }
119  return wait();
120  }
void __TBB_EXPORTED_METHOD register_pending_exception()
Records the pending exception, and cancels the task group.
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
#define __TBB_TRY
Definition: tbb_stddef.h:283
task_group_context my_context
Definition: task_group.h:105
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.

181  {
183  }
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
task_group_context my_context
Definition: task_group.h:105

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)
inlineprotected

Definition at line 123 of file task_group.h.

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

References my_root.

Referenced by run(), and tbb::task_group::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.

162  {
163  task::spawn( *prepare_task< internal::task_handle_task<F> >(h) );
164  }
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
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.

166  {
167  __TBB_TRY {
169  } __TBB_CATCH( ... ) {
170  my_context.reset();
171  __TBB_RETHROW();
172  }
174  // TODO: the reset method is not thread-safe. Ensure the correct behavior.
175  my_context.reset();
176  return canceled;
177  }
178  return complete;
179  }
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
Definition: task.h:819
#define __TBB_RETHROW()
Definition: tbb_stddef.h:286
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed.
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
#define __TBB_TRY
Definition: tbb_stddef.h:283
task_group_context my_context
Definition: task_group.h:105

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

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.