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

124  {
125  my_root = new( task::allocate_root(my_context) ) empty_task;
127  }
void set_ref_count(int count)
Set reference count.
Definition: task.h:734
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
Definition: task.h:636
task_group_context my_context
Definition: task_group.h:97

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

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

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

179  {
181  }
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:97

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

117  {
118  owner().spawn( *new( owner().allocate_additional_child_of(*my_root) ) Task( internal::forward<F>(f) ));
119  }

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

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

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

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

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

99 { 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 156 of file task_group.h.

156  {
157  internal_run< internal::task_handle_task<F> >( h );
158  }
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 160 of file task_group.h.

160  {
161  __TBB_TRY {
163  } __TBB_CATCH( ... ) {
164  my_context.reset();
165  __TBB_RETHROW();
166  }
168  // TODO: the reset method is not thread-safe. Ensure the correct behavior.
169  my_context.reset();
170  return canceled;
171  }
172  return complete;
173  }
#define __TBB_TRY
Definition: tbb_stddef.h:287
void __TBB_EXPORTED_METHOD reset()
Forcefully reinitializes the context after the task tree it was associated with is completed.
void wait_for_all()
Wait for reference count to become one, and set reference count to zero.
Definition: task.h:792
#define __TBB_CATCH(e)
Definition: tbb_stddef.h:288
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:97
#define __TBB_RETHROW()
Definition: tbb_stddef.h:290

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