Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType > Class Template Reference

Input and scheduling for a function node that takes a type Input as input. More...

#include <flow_graph.h>

Inheritance diagram for tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >:
Collaboration diagram for tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >:

Classes

class  operation_type
 

Public Types

typedef Input input_type
 The input type of this receiver. More...
 
typedef receiver< input_type >::predecessor_type predecessor_type
 
typedef predecessor_cache< input_type, null_mutexpredecessor_cache_type
 
typedef function_input_queue< input_type, A > input_queue_type
 
typedef A::template rebind< input_queue_type >::other queue_allocator_type
 
- Public Types inherited from tbb::flow::interface10::receiver< Input >
typedef Input input_type
 The input type of this receiver. More...
 
typedef internal::async_helpers< Input >::filtered_type filtered_type
 
- Public Types inherited from tbb::flow::interface10::internal::untyped_receiver
typedef untyped_sender predecessor_type
 The predecessor type for this node. More...
 

Public Member Functions

 __TBB_STATIC_ASSERT (!((internal::has_policy< queueing, Policy >::value) &&(internal::has_policy< rejecting, Policy >::value)), "queueing and rejecting policies can't be specified simultaneously")
 
 function_input_base (graph &g, size_t max_concurrency)
 Constructor for function_input_base. More...
 
 function_input_base (const function_input_base &src)
 Copy constructor. More...
 
virtual ~function_input_base ()
 Destructor. More...
 
tasktry_put_task (const input_type &t) __TBB_override
 Put item to successor; return task to run the successor if possible. More...
 
bool register_predecessor (predecessor_type &src) __TBB_override
 Adds src to the list of cached predecessors. More...
 
bool remove_predecessor (predecessor_type &src) __TBB_override
 Removes src from the list of cached predecessors. More...
 
- Public Member Functions inherited from tbb::flow::interface10::receiver< Input >
bool try_put (const typename internal::async_helpers< Input >::filtered_type &t)
 Put an item to the receiver. More...
 
bool try_put (const typename internal::async_helpers< Input >::async_type &t)
 
- Public Member Functions inherited from tbb::flow::interface10::internal::untyped_receiver
virtual ~untyped_receiver ()
 Destructor. More...
 
template<typename X >
bool try_put (const X &t)
 Put an item to the receiver. More...
 

Protected Member Functions

void reset_function_input_base (reset_flags f)
 
void reset_receiver (reset_flags f) __TBB_override
 put receiver back in initial state More...
 
graphgraph_reference () __TBB_override
 
tasktry_get_postponed_task (const input_type &i)
 
- Protected Member Functions inherited from tbb::flow::interface10::receiver< Input >
virtual tasktry_put_task_wrapper (const void *p, bool is_async) __TBB_override
 
- Protected Member Functions inherited from tbb::flow::interface10::internal::untyped_receiver
template<typename X >
tasktry_put_task (const X &t)
 
virtual bool is_continue_receiver ()
 

Protected Attributes

graphmy_graph_ref
 
const size_t my_max_concurrency
 
size_t my_concurrency
 
input_queue_typemy_queue
 
predecessor_cache< input_type, null_mutexmy_predecessors
 

Private Types

enum  op_type {
  reg_pred, rem_pred, try_fwd, tryput_bypass,
  app_body_bypass, occupy_concurrency
}
 
typedef function_input_base< Input, Policy, A, ImplType > class_type
 
typedef internal::aggregating_functor< class_type, operation_typehandler_type
 

Private Member Functions

taskperform_queued_requests ()
 
void handle_operations (operation_type *op_list)
 
void internal_try_put_task (operation_type *op)
 Put to the node, but return the task instead of enqueueing it. More...
 
void internal_forward (operation_type *op)
 Tries to spawn bodies if available and if concurrency allows. More...
 
taskinternal_try_put_bypass (const input_type &t)
 
tasktry_put_task_impl (const input_type &t, tbb::internal::true_type)
 
tasktry_put_task_impl (const input_type &t, tbb::internal::false_type)
 
taskapply_body_bypass (const input_type &i)
 Applies the body to the provided input. More...
 
taskcreate_body_task (const input_type &input)
 allocates a task to apply a body More...
 
taskforward_task ()
 This is executed by an enqueued task, the "forwarder". More...
 
taskcreate_forward_task ()
 
void spawn_forward_task ()
 Spawns a task that calls forward() More...
 

Private Attributes

bool forwarder_busy
 
aggregator< handler_type, operation_typemy_aggregator
 

Friends

class apply_body_task_bypass< class_type, input_type >
 
class forward_task_bypass< class_type >
 
class internal::aggregating_functor< class_type, operation_type >
 

Detailed Description

template<typename Input, typename Policy, typename A, typename ImplType>
class tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >

Input and scheduling for a function node that takes a type Input as input.

Definition at line 65 of file flow_graph.h.

Member Typedef Documentation

◆ class_type

template<typename Input, typename Policy, typename A, typename ImplType>
typedef function_input_base<Input, Policy, A, ImplType> tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::class_type
private

Definition at line 72 of file flow_graph.h.

◆ handler_type

template<typename Input, typename Policy, typename A, typename ImplType>
typedef internal::aggregating_functor<class_type, operation_type> tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::handler_type
private

Definition at line 228 of file flow_graph.h.

◆ input_queue_type

template<typename Input, typename Policy, typename A, typename ImplType>
typedef function_input_queue<input_type, A> tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::input_queue_type

Definition at line 80 of file flow_graph.h.

◆ input_type

template<typename Input, typename Policy, typename A, typename ImplType>
typedef Input tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::input_type

The input type of this receiver.

Definition at line 77 of file flow_graph.h.

◆ predecessor_cache_type

template<typename Input, typename Policy, typename A, typename ImplType>
typedef predecessor_cache<input_type, null_mutex > tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::predecessor_cache_type

Definition at line 79 of file flow_graph.h.

◆ predecessor_type

template<typename Input, typename Policy, typename A, typename ImplType>
typedef receiver<input_type>::predecessor_type tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::predecessor_type

Definition at line 78 of file flow_graph.h.

◆ queue_allocator_type

template<typename Input, typename Policy, typename A, typename ImplType>
typedef A::template rebind< input_queue_type >::other tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::queue_allocator_type

Definition at line 81 of file flow_graph.h.

Member Enumeration Documentation

◆ op_type

template<typename Input, typename Policy, typename A, typename ImplType>
enum tbb::flow::interface10::internal::function_input_base::op_type
private
Enumerator
reg_pred 
rem_pred 
try_fwd 
tryput_bypass 
app_body_bypass 
occupy_concurrency 

Definition at line 66 of file flow_graph.h.

84  {

Constructor & Destructor Documentation

◆ function_input_base() [1/2]

template<typename Input, typename Policy, typename A, typename ImplType>
tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::function_input_base ( graph g,
size_t  max_concurrency 
)
inline

Constructor for function_input_base.

Definition at line 91 of file flow_graph.h.

93  {};
94 
96 class continue_msg {};
97 

◆ function_input_base() [2/2]

template<typename Input, typename Policy, typename A, typename ImplType>
tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::function_input_base ( const function_input_base< Input, Policy, A, ImplType > &  src)
inline

Copy constructor.

Definition at line 101 of file flow_graph.h.

105  {
106 
107 template<typename T, typename M> class successor_cache;
108 template<typename T, typename M> class broadcast_cache;
109 template<typename T, typename M> class round_robin_cache;

◆ ~function_input_base()

template<typename Input, typename Policy, typename A, typename ImplType>
virtual tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::~function_input_base ( )
inlinevirtual

Destructor.

Definition at line 115 of file flow_graph.h.

117  {

Member Function Documentation

◆ __TBB_STATIC_ASSERT()

template<typename Input, typename Policy, typename A, typename ImplType>
tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::__TBB_STATIC_ASSERT ( (internal::has_policy< queueing, Policy >::value) &&(internal::has_policy< rejecting, Policy >::value),
"queueing and rejecting policies can't be specified simultaneously"   
)

◆ apply_body_bypass()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::apply_body_bypass ( const input_type i)
inlineprivate

Applies the body to the provided input.

Definition at line 374 of file flow_graph.h.

376  :
377  template<typename X>

◆ create_body_task()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::create_body_task ( const input_type input)
inlineprivate

allocates a task to apply a body

Definition at line 379 of file flow_graph.h.

391  { return false; }

◆ create_forward_task()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::create_forward_task ( )
inlineprivate

Definition at line 403 of file flow_graph.h.

406  { return false; }
407 

◆ forward_task()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::forward_task ( )
inlineprivate

This is executed by an enqueued task, the "forwarder".

Definition at line 388 of file flow_graph.h.

391  { return false; }
392 };
393 
394 } // namespace internal
395 
397 template< typename T >
398 class sender : public internal::untyped_sender {
399 public:
401  typedef T output_type;

◆ graph_reference()

template<typename Input, typename Policy, typename A, typename ImplType>
graph& tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::graph_reference ( )
inlineprotectedvirtual

Implements tbb::flow::interface10::internal::untyped_receiver.

Definition at line 195 of file flow_graph.h.

195  {
196  typedef async_msg<T> async_type;
197  typedef T filtered_type;
internal::async_helpers< Input >::filtered_type filtered_type
Definition: flow_graph.h:442

◆ handle_operations()

template<typename Input, typename Policy, typename A, typename ImplType>
void tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::handle_operations ( operation_type op_list)
inlineprivate

Definition at line 251 of file flow_graph.h.

252  {
253  return *static_cast<const T*>(static_cast<const async_msg<filtered_type>*>(p));
254  }
255 
256  static T& from_void_ptr(void* p) {
257  return *static_cast<T*>(static_cast<async_msg<filtered_type>*>(p));
258  }
259 
260  // Used in receiver<T> class
261  static task* try_put_task_wrapper_impl(receiver<T>* const this_recv, const void *p, bool is_async) {
262  if (is_async) {
263  // Both are async
264  return this_recv->try_put_task(from_void_ptr(p));
265  }
266  else {
267  // This (T) is async and incoming 'X t' is NOT async
268  // Create async_msg for X
270  const T msg(t);
271  return this_recv->try_put_task(msg);
272  }
273  }
274 };
275 
276 class untyped_receiver;
277 
278 class untyped_sender {
279  template< typename, typename > friend class internal::predecessor_cache;
280  template< typename, typename > friend class internal::reservable_predecessor_cache;
281 public:
283  typedef untyped_receiver successor_type;
284 
285  virtual ~untyped_sender() {}
286 
287  // NOTE: Following part of PUBLIC section is copy-paste from original sender<T> class
288 
289  // TODO: Prevent untyped successor registration
290 
292  virtual bool register_successor( successor_type &r ) = 0;
293 
295  virtual bool remove_successor( successor_type &r ) = 0;
296 
298  virtual bool try_release( ) { return false; }
299 
301  virtual bool try_consume( ) { return false; }
302 
303 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
304  typedef internal::edge_container<successor_type> built_successors_type;
306  typedef built_successors_type::edge_list_type successor_list_type;
307  virtual built_successors_type &built_successors() = 0;
308  virtual void internal_add_built_successor( successor_type & ) = 0;
309  virtual void internal_delete_built_successor( successor_type & ) = 0;
310  virtual void copy_successors( successor_list_type &) = 0;
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 * task
An cache of predecessors that supports requests and reservations.
static const T & from_void_ptr(const void *p)
Definition: flow_graph.h:209
void const char const char int ITT_FORMAT __itt_group_sync p
A cache of predecessors that only supports try_get.
internal::async_helpers< Input >::filtered_type filtered_type
Definition: flow_graph.h:442

◆ internal_forward()

template<typename Input, typename Policy, typename A, typename ImplType>
void tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::internal_forward ( operation_type op)
inlineprivate

Tries to spawn bodies if available and if concurrency allows.

Definition at line 330 of file flow_graph.h.

330  {
331  template< typename, typename > friend class run_and_put_task;
332  template< typename > friend class limiter_node;
333 
334  template< typename, typename > friend class internal::broadcast_cache;
335  template< typename, typename > friend class internal::round_robin_cache;
336  template< typename, typename > friend class internal::successor_cache;
337 
338 #if __TBB_PREVIEW_OPENCL_NODE
339  template< typename, typename > friend class proxy_dependency_receiver;
340 #endif /* __TBB_PREVIEW_OPENCL_NODE */
A cache of successors that are put in a round-robin fashion.
An abstract cache of successors.
A cache of successors that are broadcast to.

◆ internal_try_put_bypass()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::internal_try_put_bypass ( const input_type t)
inlineprivate

Definition at line 342 of file flow_graph.h.

346  {}
347 
349  template<typename X>

◆ internal_try_put_task()

template<typename Input, typename Policy, typename A, typename ImplType>
void tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::internal_try_put_task ( operation_type op)
inlineprivate

Put to the node, but return the task instead of enqueueing it.

Definition at line 313 of file flow_graph.h.

313  :
315  template< typename X >
316  bool try_get( X &t ) {
318  }
319 
321  template< typename X >
322  bool try_reserve( X &t ) {
324  }
325 
326  virtual bool try_get_wrapper( void* p, bool is_async ) = 0;
327  virtual bool try_reserve_wrapper( void* p, bool is_async ) = 0;
void const char const char int ITT_FORMAT __itt_group_sync p
static const void * to_void_ptr(const T &t)
Definition: flow_graph.h:201

◆ perform_queued_requests()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::perform_queued_requests ( )
inlineprivate

Definition at line 232 of file flow_graph.h.

236  {
237  typedef T async_type;
238  typedef typename T::async_msg_data_type filtered_type;
239 
240  static const bool is_async_type = true;
241 
242  // Receiver-classes use const interfaces
243  static const void* to_void_ptr(const T& t) {
244  return static_cast<const void*>(&static_cast<const async_msg<filtered_type>&>(t));
245  }
246 
247  static void* to_void_ptr(T& t) {
248  return static_cast<void*>(&static_cast<async_msg<filtered_type>&>(t));
249  }
250 
internal::async_helpers< Input >::filtered_type filtered_type
Definition: flow_graph.h:442

◆ register_predecessor()

template<typename Input, typename Policy, typename A, typename ImplType>
bool tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::register_predecessor ( predecessor_type src)
inlinevirtual

Adds src to the list of cached predecessors.

Reimplemented from tbb::flow::interface10::internal::untyped_receiver.

Definition at line 124 of file flow_graph.h.

126  {
127  for (typename edge_list_type::iterator i = built_edges.begin(); i != built_edges.end(); ++i) {
128  if (*i == &s) {
129  (void)built_edges.erase(i);
void const char const char int ITT_FORMAT __itt_group_sync s

◆ remove_predecessor()

template<typename Input, typename Policy, typename A, typename ImplType>
bool tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::remove_predecessor ( predecessor_type src)
inlinevirtual

Removes src from the list of cached predecessors.

Reimplemented from tbb::flow::interface10::internal::untyped_receiver.

Definition at line 132 of file flow_graph.h.

135  {
136  v = built_edges;
137  }

◆ reset_function_input_base()

template<typename Input, typename Policy, typename A, typename ImplType>
void tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::reset_function_input_base ( reset_flags  f)
inlineprotected

Definition at line 173 of file flow_graph.h.

178  {
179  // both are valid tasks
void spawn_in_graph_arena(graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.

◆ reset_receiver()

template<typename Input, typename Policy, typename A, typename ImplType>
void tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::reset_receiver ( reset_flags  f)
inlineprotectedvirtual

put receiver back in initial state

Implements tbb::flow::interface10::internal::untyped_receiver.

Definition at line 188 of file flow_graph.h.

190  {
191 
192 template < typename T > class async_storage;
193 

◆ spawn_forward_task()

template<typename Input, typename Policy, typename A, typename ImplType>
void tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::spawn_forward_task ( )
inlineprivate

Spawns a task that calls forward()

Definition at line 410 of file flow_graph.h.

411  :
412  virtual bool try_get_wrapper( void* p, bool is_async ) __TBB_override {
413  // Both async OR both are NOT async
414  if ( internal::async_helpers<T>::is_async_type == is_async ) {
415  return try_get( internal::async_helpers<T>::from_void_ptr(p) );
static const T & from_void_ptr(const void *p)
Definition: flow_graph.h:209
#define __TBB_override
Definition: tbb_stddef.h:244
void const char const char int ITT_FORMAT __itt_group_sync p

◆ try_get_postponed_task()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::try_get_postponed_task ( const input_type i)
inlineprotected

Definition at line 199 of file flow_graph.h.

201  {
202  return static_cast<const void*>(&t);
203  }

◆ try_put_task()

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::try_put_task ( const input_type t)
inlinevirtual

Put item to successor; return task to run the successor if possible.

Implements tbb::flow::interface10::receiver< Input >.

Definition at line 119 of file flow_graph.h.

119  :
120  typedef std::list<C *, tbb::tbb_allocator<C *> > edge_list_type;
121 

◆ try_put_task_impl() [1/2]

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::try_put_task_impl ( const input_type t,
tbb::internal::true_type   
)
inlineprivate

Definition at line 351 of file flow_graph.h.

362  { return false; }

◆ try_put_task_impl() [2/2]

template<typename Input, typename Policy, typename A, typename ImplType>
task* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::try_put_task_impl ( const input_type t,
tbb::internal::false_type   
)
inlineprivate

Definition at line 364 of file flow_graph.h.

365  { return false; }
366 
367 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
368  typedef internal::edge_container<predecessor_type> built_predecessors_type;
369  typedef built_predecessors_type::edge_list_type predecessor_list_type;
370  virtual built_predecessors_type &built_predecessors() = 0;

Friends And Related Function Documentation

◆ apply_body_task_bypass< class_type, input_type >

template<typename Input, typename Policy, typename A, typename ImplType>
friend class apply_body_task_bypass< class_type, input_type >
friend

Definition at line 207 of file flow_graph.h.

◆ forward_task_bypass< class_type >

template<typename Input, typename Policy, typename A, typename ImplType>
friend class forward_task_bypass< class_type >
friend

Definition at line 208 of file flow_graph.h.

◆ internal::aggregating_functor< class_type, operation_type >

template<typename Input, typename Policy, typename A, typename ImplType>
friend class internal::aggregating_functor< class_type, operation_type >
friend

Definition at line 229 of file flow_graph.h.

Member Data Documentation

◆ forwarder_busy

template<typename Input, typename Policy, typename A, typename ImplType>
bool tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::forwarder_busy
private

Definition at line 227 of file flow_graph.h.

◆ my_aggregator

template<typename Input, typename Policy, typename A, typename ImplType>
aggregator< handler_type, operation_type > tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::my_aggregator
private

Definition at line 230 of file flow_graph.h.

◆ my_concurrency

template<typename Input, typename Policy, typename A, typename ImplType>
size_t tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::my_concurrency
protected

Definition at line 184 of file flow_graph.h.

◆ my_graph_ref

template<typename Input, typename Policy, typename A, typename ImplType>
graph& tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::my_graph_ref
protected

Definition at line 182 of file flow_graph.h.

◆ my_max_concurrency

template<typename Input, typename Policy, typename A, typename ImplType>
const size_t tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::my_max_concurrency
protected

Definition at line 183 of file flow_graph.h.

◆ my_predecessors

template<typename Input, typename Policy, typename A, typename ImplType>
predecessor_cache<input_type, null_mutex > tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::my_predecessors
protected

Definition at line 186 of file flow_graph.h.

◆ my_queue

template<typename Input, typename Policy, typename A, typename ImplType>
input_queue_type* tbb::flow::interface10::internal::function_input_base< Input, Policy, A, ImplType >::my_queue
protected

Definition at line 185 of file flow_graph.h.


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

Copyright © 2005-2018 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.