Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
tbb::flow::interface10::internal::reserving_port< T > Class Template Reference

The two-phase join port. More...

#include <flow_graph.h>

Inheritance diagram for tbb::flow::interface10::internal::reserving_port< T >:
Collaboration diagram for tbb::flow::interface10::internal::reserving_port< T >:

Classes

class  reserving_port_operation
 

Public Types

typedef T input_type
 
typedef receiver< input_type >::predecessor_type predecessor_type
 
- Public Types inherited from tbb::flow::interface10::receiver< T >
typedef T input_type
 The input type of this receiver. More...
 
typedef internal::async_helpers< T >::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

 reserving_port ()
 Constructor. More...
 
 reserving_port (const reserving_port &)
 
void set_join_node_pointer (forwarding_base *join)
 
bool register_predecessor (predecessor_type &src) __TBB_override
 Add a predecessor. More...
 
bool remove_predecessor (predecessor_type &src) __TBB_override
 Remove a predecessor. More...
 
bool reserve (T &v)
 Reserve an item from the port. More...
 
void release ()
 Release the port. More...
 
void consume ()
 Complete use of the port. More...
 
void reset_receiver (reset_flags f) __TBB_override
 put receiver back in initial state More...
 
- Public Member Functions inherited from tbb::flow::interface10::receiver< T >
bool try_put (const typename internal::async_helpers< T >::filtered_type &t)
 Put an item to the receiver. More...
 
bool try_put (const typename internal::async_helpers< T >::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

tasktry_put_task (const T &) __TBB_override
 Put item to successor; return task to run the successor if possible. More...
 
graphgraph_reference () __TBB_override
 
- Protected Member Functions inherited from tbb::flow::interface10::receiver< T >
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 ()
 

Private Types

enum  op_type {
  reg_pred, rem_pred, res_item, rel_res,
  con_res
}
 
typedef reserving_port< T > class_type
 
typedef internal::aggregating_functor< class_type, reserving_port_operationhandler_type
 

Private Member Functions

void handle_operations (reserving_port_operation *op_list)
 

Private Attributes

aggregator< handler_type, reserving_port_operationmy_aggregator
 
forwarding_basemy_join
 
reservable_predecessor_cache< T, null_mutexmy_predecessors
 
bool reserved
 

Friends

class internal::aggregating_functor< class_type, reserving_port_operation >
 
template<typename R , typename B >
class run_and_put_task
 
template<typename X , typename Y >
class internal::broadcast_cache
 
template<typename X , typename Y >
class internal::round_robin_cache
 

Detailed Description

template<typename T>
class tbb::flow::interface10::internal::reserving_port< T >

The two-phase join port.

Definition at line 210 of file flow_graph.h.

Member Typedef Documentation

◆ class_type

template<typename T >
typedef reserving_port<T> tbb::flow::interface10::internal::reserving_port< T >::class_type
private

Definition at line 225 of file flow_graph.h.

◆ handler_type

template<typename T >
typedef internal::aggregating_functor<class_type, reserving_port_operation> tbb::flow::interface10::internal::reserving_port< T >::handler_type
private

Definition at line 245 of file flow_graph.h.

◆ input_type

template<typename T >
typedef T tbb::flow::interface10::internal::reserving_port< T >::input_type

Definition at line 212 of file flow_graph.h.

◆ predecessor_type

Member Enumeration Documentation

◆ op_type

Enumerator
reg_pred 
rem_pred 
res_item 
rel_res 
con_res 

Definition at line 220 of file flow_graph.h.

228  {

Constructor & Destructor Documentation

◆ reserving_port() [1/2]

template<typename T >
tbb::flow::interface10::internal::reserving_port< T >::reserving_port ( )
inline

Constructor.

Definition at line 330 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;
A cache of successors that are broadcast to.
A cache of successors that are put in a round-robin fashion.

◆ reserving_port() [2/2]

template<typename T >
tbb::flow::interface10::internal::reserving_port< T >::reserving_port ( const reserving_port< T > &  )
inline

Definition at line 337 of file flow_graph.h.

340  :
342  typedef untyped_sender predecessor_type;
receiver< input_type >::predecessor_type predecessor_type
Definition: flow_graph.h:213

Member Function Documentation

◆ consume()

template<typename T >
void tbb::flow::interface10::internal::reserving_port< T >::consume ( )
inline

Complete use of the port.

Definition at line 376 of file flow_graph.h.

377  {
379  }
static const void * to_void_ptr(const T &t)
Definition: flow_graph.h:201
virtual task * try_put_task_wrapper(const void *p, bool is_async) __TBB_override
Definition: flow_graph.h:453

◆ graph_reference()

template<typename T >
graph& tbb::flow::interface10::internal::reserving_port< T >::graph_reference ( )
inlineprotectedvirtual

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

Definition at line 323 of file flow_graph.h.

330  {

◆ handle_operations()

template<typename T >
void tbb::flow::interface10::internal::reserving_port< T >::handle_operations ( reserving_port_operation op_list)
inlineprivate

Definition at line 249 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;
311  virtual size_t successor_count() = 0;
312 #endif /* TBB_DEPRECATED_FLOW_NODE_EXTRACTION */
313 protected:
internal::async_helpers< T >::filtered_type filtered_type
Definition: flow_graph.h:441
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 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
A cache of predecessors that only supports try_get.
void const char const char int ITT_FORMAT __itt_group_sync p

◆ register_predecessor()

template<typename T >
bool tbb::flow::interface10::internal::reserving_port< T >::register_predecessor ( predecessor_type src)
inlinevirtual

Add a predecessor.

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

Definition at line 349 of file flow_graph.h.

349  {
350  task *res = try_put_task(t);
351  if (!res) return false;
353  return true;
task * try_put_task(const T &) __TBB_override
Put item to successor; return task to run the successor if possible.
Definition: flow_graph.h:319
void spawn_in_graph_arena(graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
static tbb::task *const SUCCESSFULLY_ENQUEUED
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

◆ release()

template<typename T >
void tbb::flow::interface10::internal::reserving_port< T >::release ( )
inline

Release the port.

Definition at line 370 of file flow_graph.h.

375  :
376  template<typename X>

◆ remove_predecessor()

template<typename T >
bool tbb::flow::interface10::internal::reserving_port< T >::remove_predecessor ( predecessor_type src)
inlinevirtual

Remove a predecessor.

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

Definition at line 356 of file flow_graph.h.

361  { return false; }

◆ reserve()

template<typename T >
bool tbb::flow::interface10::internal::reserving_port< T >::reserve ( T &  v)
inline

Reserve an item from the port.

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;

◆ reset_receiver()

template<typename T >
void tbb::flow::interface10::internal::reserving_port< T >::reset_receiver ( reset_flags  f)
inlinevirtual

put receiver back in initial state

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

Definition at line 411 of file flow_graph.h.

411  {
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  }
416  // Else: this (T) is async OR incoming 't' is async
417  __TBB_ASSERT(false, "async_msg interface does not support 'pull' protocol in try_get()");
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
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

◆ set_join_node_pointer()

template<typename T >
void tbb::flow::interface10::internal::reserving_port< T >::set_join_node_pointer ( forwarding_base join)
inline

Definition at line 344 of file flow_graph.h.

345  {}
346 

◆ try_put_task()

template<typename T >
task* tbb::flow::interface10::internal::reserving_port< T >::try_put_task ( const T &  t)
inlineprotectedvirtual

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

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

Definition at line 319 of file flow_graph.h.

322  {

Friends And Related Function Documentation

◆ internal::aggregating_functor< class_type, reserving_port_operation >

template<typename T >
friend class internal::aggregating_functor< class_type, reserving_port_operation >
friend

Definition at line 246 of file flow_graph.h.

◆ internal::broadcast_cache

template<typename T >
template<typename X , typename Y >
friend class internal::broadcast_cache
friend

Definition at line 317 of file flow_graph.h.

◆ internal::round_robin_cache

template<typename T >
template<typename X , typename Y >
friend class internal::round_robin_cache
friend

Definition at line 318 of file flow_graph.h.

◆ run_and_put_task

template<typename T >
template<typename R , typename B >
friend class run_and_put_task
friend

Definition at line 316 of file flow_graph.h.

Member Data Documentation

◆ my_aggregator

template<typename T >
aggregator<handler_type, reserving_port_operation> tbb::flow::interface10::internal::reserving_port< T >::my_aggregator
private

Definition at line 247 of file flow_graph.h.

◆ my_join

template<typename T >
forwarding_base* tbb::flow::interface10::internal::reserving_port< T >::my_join
private

Definition at line 420 of file flow_graph.h.

◆ my_predecessors

template<typename T >
reservable_predecessor_cache< T, null_mutex > tbb::flow::interface10::internal::reserving_port< T >::my_predecessors
private

Definition at line 421 of file flow_graph.h.

◆ reserved

template<typename T >
bool tbb::flow::interface10::internal::reserving_port< T >::reserved
private

Definition at line 422 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.