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

taskowner ()
 
template<typename F >
task_group_status internal_run_and_wait (F &f)
 
template<typename Task , typename F >
void internal_run (__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 ()
 Allow default construction. More...
 

Detailed Description

Definition at line 80 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 118 of file task_group.h.

120  {
121  my_root = new( task::allocate_root(my_context) ) empty_task;
123  }
task_group_context my_context
Definition: task_group.h:93
void set_ref_count(int count)
Set reference count.
Definition: task.h:731
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
Definition: task.h:633

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 125 of file task_group.h.

125  {
126  if( my_root->ref_count() > 1 ) {
127 #if __TBB_CPP17_UNCAUGHT_EXCEPTIONS_PRESENT
128  bool stack_unwinding_in_progress = std::uncaught_exceptions() > 0;
129 #else
130  bool stack_unwinding_in_progress = std::uncaught_exception();
131 #endif
132  // Always attempt to do proper cleanup to avoid inevitable memory corruption
133  // in case of missing wait (for the sake of better testability & debuggability)
134  if ( !is_canceling() )
135  cancel();
136  __TBB_TRY {
138  } __TBB_CATCH (...) {
139  task::destroy(*my_root);
140  __TBB_RETHROW();
141  }
142  task::destroy(*my_root);
143  if ( !stack_unwinding_in_progress )
145  }
146  else {
147  task::destroy(*my_root);
148  }
149  }
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
#define __TBB_TRY
Definition: tbb_stddef.h:283
int ref_count() const
The internal reference count.
Definition: task.h:867
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
#define __TBB_RETHROW()
Definition: tbb_stddef.h:286
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
Definition: task.h:789

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 175 of file task_group.h.

175  {
177  }
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:93

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

template<typename Task , typename F >
void tbb::internal::task_group_base::internal_run ( __TBB_FORWARDING_REF(F)  f)
inlineprotected

Definition at line 113 of file task_group.h.

113  {
114  owner().spawn( *new( owner().allocate_additional_child_of(*my_root) ) Task( internal::forward<F>(f) ));
115  }

References my_root, and owner().

Here is the call 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 98 of file task_group.h.

98  {
99  __TBB_TRY {
101  // We need to increase the reference count of the root task to notify waiters that
102  // this task group has some work in progress.
103  ref_count_guard guard(*my_root);
104  f();
105  }
106  } __TBB_CATCH( ... ) {
108  }
109  return wait();
110  }
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
void __TBB_EXPORTED_METHOD register_pending_exception()
Records the pending exception, and cancels the task group.
#define __TBB_TRY
Definition: tbb_stddef.h:283
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:93
task_group_status wait()
Definition: task_group.h:156

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 171 of file task_group.h.

171  {
173  }
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:93

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:

◆ owner()

task& tbb::internal::task_group_base::owner ( )
inlineprotected

Definition at line 95 of file task_group.h.

95 { return *my_root; }

References my_root.

Referenced by internal_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 152 of file task_group.h.

152  {
153  internal_run< internal::task_handle_task<F> >( h );
154  }
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

References h.

◆ wait()

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

Definition at line 156 of file task_group.h.

156  {
157  __TBB_TRY {
159  } __TBB_CATCH( ... ) {
160  my_context.reset();
161  __TBB_RETHROW();
162  }
164  // TODO: the reset method is not thread-safe. Ensure the correct behavior.
165  my_context.reset();
166  return canceled;
167  }
168  return complete;
169  }
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:284
#define __TBB_TRY
Definition: tbb_stddef.h:283
bool __TBB_EXPORTED_METHOD is_group_execution_cancelled() const
Returns true if the context received cancellation request.
#define __TBB_RETHROW()
Definition: tbb_stddef.h:286
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
Definition: task.h:789
task_group_context my_context
Definition: task_group.h:93
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 93 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-2019 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.