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, __TBB_FLOW_GRAPH_PRIORITY_ARG1(size_t max_concurrency, node_priority_t priority))
 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)
 Creates tasks for postponed messages 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 61 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 68 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 227 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 76 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 73 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 75 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 74 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 77 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 62 of file flow_graph.h.

80  {

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,
__TBB_FLOW_GRAPH_PRIORITY_ARG1(size_t max_concurrency, node_priority_t priority)   
)
inline

Constructor for function_input_base.

Definition at line 87 of file flow_graph.h.

89  {};
90 
92 class continue_msg {};
93 
95 template< typename T > class sender;
96 template< typename T > class receiver;

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

99  {
100 template< typename T, typename U > class limiter_node; // needed for resetting decrementer
101 }
102 namespace interface10 {
103 template< typename R, typename B > class run_and_put_task;
104 
105 namespace internal {
106 
107 template<typename T, typename M> class successor_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 113 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 373 of file flow_graph.h.

375  :
376  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 378 of file flow_graph.h.

390  { 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 402 of file flow_graph.h.

405  { return false; }
406 

◆ 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 387 of file flow_graph.h.

390  { return false; }
391 };
392 
393 } // namespace internal
394 
396 template< typename T >
397 class sender : public internal::untyped_sender {
398 public:
400  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 194 of file flow_graph.h.

195  {
196  typedef async_msg<T> async_type;

◆ 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 250 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;
A cache of predecessors that only supports try_get.
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 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
internal::async_helpers< Input >::filtered_type filtered_type
Definition: flow_graph.h:441
An cache of predecessors that supports requests and reservations.
void const char const char int ITT_FORMAT __itt_group_sync p

◆ 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

Creates tasks for postponed messages if available and if concurrency allows.

Definition at line 329 of file flow_graph.h.

330  {
331  template< typename, typename > friend class run_and_put_task;
332 
333  template< typename, typename > friend class internal::broadcast_cache;
334  template< typename, typename > friend class internal::round_robin_cache;
335  template< typename, typename > friend class internal::successor_cache;
336 
337 #if __TBB_PREVIEW_OPENCL_NODE
338  template< typename, typename > friend class proxy_dependency_receiver;
339 #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 341 of file flow_graph.h.

345  {}
346 
348  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 312 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;
static const void * to_void_ptr(const T &t)
Definition: flow_graph.h:201
void const char const char int ITT_FORMAT __itt_group_sync p

◆ 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 231 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  }
internal::async_helpers< Input >::filtered_type filtered_type
Definition: flow_graph.h:441

◆ 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 122 of file flow_graph.h.

122  {
123  built_edges.push_back(&s);
124  }
125 
126  void delete_edge(C &s) {
127  for (typename edge_list_type::iterator i = built_edges.begin(); i != built_edges.end(); ++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 130 of file flow_graph.h.

135  {

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

171  {
172  // if no RHS task, don't change left.
173  if (right == NULL) return left;
174  // right != NULL
175  if (left == NULL) return right;
176  if (left == SUCCESSFULLY_ENQUEUED) return right;
177  // left contains a task
178  if (right != SUCCESSFULLY_ENQUEUED) {
static tbb::task *const SUCCESSFULLY_ENQUEUED

◆ 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 187 of file flow_graph.h.

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

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

410  :
411  virtual bool try_get_wrapper( void* p, bool is_async ) __TBB_override {
412  // Both async OR both are NOT async
413  if ( internal::async_helpers<T>::is_async_type == is_async ) {
414  return try_get( internal::async_helpers<T>::from_void_ptr(p) );
415  }
#define __TBB_override
Definition: tbb_stddef.h:240
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

◆ 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 198 of file flow_graph.h.

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

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

117  {
118 
119 public:

◆ 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 350 of file flow_graph.h.

361  { 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 363 of file flow_graph.h.

364  { return false; }
365 
366 #if TBB_DEPRECATED_FLOW_NODE_EXTRACTION
367  typedef internal::edge_container<predecessor_type> built_predecessors_type;
368  typedef built_predecessors_type::edge_list_type predecessor_list_type;
369  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 206 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 207 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 228 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 226 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 229 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 182 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 180 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 181 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 185 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 184 of file flow_graph.h.


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.