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

#include <flow_graph.h>

Inheritance diagram for tbb::flow::interface10a::overwrite_node< T >:
Collaboration diagram for tbb::flow::interface10a::overwrite_node< T >:

Classes

struct  register_predecessor_task
 Breaks an infinite loop between the node reservation and register_successor call. More...
 

Public Types

typedef T input_type
 
typedef T output_type
 
typedef receiver< input_type >::predecessor_type predecessor_type
 
typedef sender< output_type >::successor_type successor_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 Types inherited from tbb::flow::interface10::sender< T >
typedef T output_type
 The output type of this sender. More...
 
typedef internal::async_helpers< T >::filtered_type filtered_type
 
- Public Types inherited from tbb::flow::interface10::internal::untyped_sender
typedef untyped_receiver successor_type
 The successor type for this node. More...
 

Public Member Functions

 overwrite_node (graph &g)
 
 overwrite_node (const overwrite_node &src)
 Copy constructor; doesn't take anything from src; default won't work. More...
 
 ~overwrite_node ()
 
bool register_successor (successor_type &s) __TBB_override
 Add a new successor to this node. More...
 
bool remove_successor (successor_type &s) __TBB_override
 Removes a successor from this node. More...
 
bool try_get (input_type &v) __TBB_override
 Request an item from the sender. More...
 
bool try_reserve (T &v) __TBB_override
 Reserves an item. More...
 
bool try_release () __TBB_override
 Releases the reserved item. More...
 
bool try_consume () __TBB_override
 Consumes the reserved item. More...
 
bool is_valid ()
 
void clear ()
 
- Public Member Functions inherited from tbb::flow::interface10::graph_node
 graph_node (graph &g)
 
virtual ~graph_node ()
 
- 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...
 
virtual bool register_predecessor (predecessor_type &)
 Add a predecessor to the node. More...
 
virtual bool remove_predecessor (predecessor_type &)
 Remove a predecessor from the node. More...
 
- Public Member Functions inherited from tbb::flow::interface10::internal::untyped_sender
virtual ~untyped_sender ()
 

Protected Member Functions

tasktry_put_task (const input_type &v) __TBB_override
 Put item to successor; return task to run the successor if possible. More...
 
tasktry_put_task_impl (const input_type &v)
 
graphgraph_reference () __TBB_override
 
void reset_receiver (reset_flags) __TBB_override
 put receiver back in initial state More...
 
void reset_node (reset_flags f) __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 ()
 
- Protected Member Functions inherited from tbb::flow::interface10::sender< T >
virtual bool try_get_wrapper (void *p, bool is_async) __TBB_override
 
virtual bool try_reserve_wrapper (void *p, bool is_async) __TBB_override
 
- Protected Member Functions inherited from tbb::flow::interface10::internal::untyped_sender
template<typename X >
bool try_get (X &t)
 Request an item from the sender. More...
 
template<typename X >
bool try_reserve (X &t)
 Reserves an item in the sender. More...
 

Protected Attributes

spin_mutex my_mutex
 
internal::broadcast_cache< input_type, null_rw_mutexmy_successors
 
input_type my_buffer
 
bool my_buffer_is_valid
 
- Protected Attributes inherited from tbb::flow::interface10::graph_node
graphmy_graph
 
graph_nodenext
 
graph_nodeprev
 

Friends

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::interface10a::overwrite_node< T >

Definition at line 3656 of file flow_graph.h.

Member Typedef Documentation

◆ input_type

template<typename T >
typedef T tbb::flow::interface10a::overwrite_node< T >::input_type

Definition at line 3658 of file flow_graph.h.

◆ output_type

template<typename T >
typedef T tbb::flow::interface10a::overwrite_node< T >::output_type

Definition at line 3659 of file flow_graph.h.

◆ predecessor_type

Definition at line 3660 of file flow_graph.h.

◆ successor_type

Definition at line 3661 of file flow_graph.h.

Constructor & Destructor Documentation

◆ overwrite_node() [1/2]

template<typename T >
tbb::flow::interface10a::overwrite_node< T >::overwrite_node ( graph g)
inlineexplicit

Definition at line 3669 of file flow_graph.h.

3669  : graph_node(g), my_buffer_is_valid(false) {
3670  my_successors.set_owner( this );
3671  tbb::internal::fgt_node( tbb::internal::FLOW_OVERWRITE_NODE, &this->my_graph,
3672  static_cast<receiver<input_type> *>(this), static_cast<sender<output_type> *>(this) );
3673  }
internal::broadcast_cache< input_type, null_rw_mutex > my_successors
Definition: flow_graph.h:3844
static void fgt_node(string_index, void *, void *)

References tbb::internal::fgt_node(), and tbb::flow::interface10::internal::successor_cache< T, M >::set_owner().

Here is the call graph for this function:

◆ overwrite_node() [2/2]

template<typename T >
tbb::flow::interface10a::overwrite_node< T >::overwrite_node ( const overwrite_node< T > &  src)
inline

Copy constructor; doesn't take anything from src; default won't work.

Definition at line 3676 of file flow_graph.h.

3676  :
3677  graph_node(src.my_graph), receiver<T>(), sender<T>(), my_buffer_is_valid(false)
3678  {
3679  my_successors.set_owner( this );
3680  tbb::internal::fgt_node( tbb::internal::FLOW_OVERWRITE_NODE, &this->my_graph,
3681  static_cast<receiver<input_type> *>(this), static_cast<sender<output_type> *>(this) );
3682  }
internal::broadcast_cache< input_type, null_rw_mutex > my_successors
Definition: flow_graph.h:3844
static void fgt_node(string_index, void *, void *)

References tbb::internal::fgt_node(), and tbb::flow::interface10::internal::successor_cache< T, M >::set_owner().

Here is the call graph for this function:

◆ ~overwrite_node()

template<typename T >
tbb::flow::interface10a::overwrite_node< T >::~overwrite_node ( )
inline

Definition at line 3684 of file flow_graph.h.

3684 {}

Member Function Documentation

◆ clear()

template<typename T >
void tbb::flow::interface10a::overwrite_node< T >::clear ( )
inline

Definition at line 3799 of file flow_graph.h.

◆ graph_reference()

template<typename T >
graph& tbb::flow::interface10a::overwrite_node< T >::graph_reference ( )
inlineprotectedvirtual

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

Definition at line 3822 of file flow_graph.h.

3822  {
3823  return my_graph;
3824  }

◆ is_valid()

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::is_valid ( )
inline

Definition at line 3794 of file flow_graph.h.

◆ register_successor()

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::register_successor ( successor_type r)
inlinevirtual

Add a new successor to this node.

Implements tbb::flow::interface10::internal::untyped_sender.

Definition at line 3692 of file flow_graph.h.

3692  {
3695  // We have a valid value that must be forwarded immediately.
3696  bool ret = s.try_put( my_buffer );
3697  if ( ret ) {
3698  // We add the successor that accepted our put
3699  my_successors.register_successor( s );
3700  } else {
3701  // In case of reservation a race between the moment of reservation and register_successor can appear,
3702  // because failed reserve does not mean that register_successor is not ready to put a message immediately.
3703  // We have some sort of infinite loop: reserving node tries to set pull state for the edge,
3704  // but overwrite_node tries to return push state back. That is why we have to break this loop with task creation.
3705  task *rtask = new ( task::allocate_additional_child_of( *( my_graph.root_task() ) ) )
3706  register_predecessor_task( *this, s );
3708  }
3709  } else {
3710  // No valid value yet, just add as successor
3711  my_successors.register_successor( s );
3712  }
3713  return true;
3714  }
tbb::task * root_task()
Returns the root task of the graph.
friend class scoped_lock
Definition: spin_mutex.h:180
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::broadcast_cache< input_type, null_rw_mutex > my_successors
Definition: flow_graph.h:3844
void const char const char int ITT_FORMAT __itt_group_sync s
void spawn_in_graph_arena(graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.

References tbb::flow::interface10::internal::is_graph_active(), tbb::flow::interface10::internal::successor_cache< T, M >::register_successor(), s, and tbb::flow::interface10::internal::spawn_in_graph_arena().

Here is the call graph for this function:

◆ remove_successor()

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::remove_successor ( successor_type r)
inlinevirtual

Removes a successor from this node.

Implements tbb::flow::interface10::internal::untyped_sender.

Definition at line 3716 of file flow_graph.h.

3716  {
3718  my_successors.remove_successor(s);
3719  return true;
3720  }
friend class scoped_lock
Definition: spin_mutex.h:180
internal::broadcast_cache< input_type, null_rw_mutex > my_successors
Definition: flow_graph.h:3844
void const char const char int ITT_FORMAT __itt_group_sync s

References tbb::flow::interface10::internal::successor_cache< T, M >::remove_successor(), and s.

Here is the call graph for this function:

◆ reset_node()

template<typename T >
void tbb::flow::interface10a::overwrite_node< T >::reset_node ( reset_flags  f)
inlineprotectedvirtual

Implements tbb::flow::interface10::graph_node.

Definition at line 3852 of file flow_graph.h.

3852  {
3853  my_buffer_is_valid = false;
3854  if (f&rf_clear_edges) {
3855  my_successors.clear();
3856  }
3857  }
internal::broadcast_cache< input_type, null_rw_mutex > my_successors
Definition: flow_graph.h:3844

References tbb::flow::interface10::internal::successor_cache< T, M >::clear(), and tbb::flow::interface10::rf_clear_edges.

Here is the call graph for this function:

◆ reset_receiver()

template<typename T >
void tbb::flow::interface10a::overwrite_node< T >::reset_receiver ( reset_flags  f)
inlineprotectedvirtual

put receiver back in initial state

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

Definition at line 3850 of file flow_graph.h.

3850 {}

◆ try_consume()

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::try_consume ( )
inlinevirtual

Consumes the reserved item.

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

Definition at line 3792 of file flow_graph.h.

3792 { return true; }

◆ try_get()

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::try_get ( input_type )
inlinevirtual

Request an item from the sender.

Reimplemented from tbb::flow::interface10::sender< T >.

Definition at line 3774 of file flow_graph.h.

3774  {
3776  if ( my_buffer_is_valid ) {
3777  v = my_buffer;
3778  return true;
3779  }
3780  return false;
3781  }
friend class scoped_lock
Definition: spin_mutex.h:180

◆ try_put_task()

template<typename T >
task* tbb::flow::interface10a::overwrite_node< T >::try_put_task ( const input_type t)
inlineprotectedvirtual

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

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

Reimplemented in tbb::flow::interface10a::write_once_node< T >.

Definition at line 3809 of file flow_graph.h.

3809  {
3811  return try_put_task_impl(v);
3812  }
friend class scoped_lock
Definition: spin_mutex.h:180
task * try_put_task_impl(const input_type &v)
Definition: flow_graph.h:3814

References internal::successor_cache< T, M >::my_mutex.

◆ try_put_task_impl()

template<typename T >
task* tbb::flow::interface10a::overwrite_node< T >::try_put_task_impl ( const input_type v)
inlineprotected

Definition at line 3814 of file flow_graph.h.

3814  {
3815  my_buffer = v;
3816  my_buffer_is_valid = true;
3817  task * rtask = my_successors.try_put_task(v);
3818  if (!rtask) rtask = SUCCESSFULLY_ENQUEUED;
3819  return rtask;
3820  }
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
internal::broadcast_cache< input_type, null_rw_mutex > my_successors
Definition: flow_graph.h:3844

References internal::successor_cache< T, M >::my_successors, and tbb::flow::internal::SUCCESSFULLY_ENQUEUED.

◆ try_release()

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::try_release ( )
inlinevirtual

Releases the reserved item.

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

Definition at line 3789 of file flow_graph.h.

3789 { return true; }

◆ try_reserve()

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::try_reserve ( T &  v)
inlinevirtual

Reserves an item.

Reimplemented from tbb::flow::interface10::sender< T >.

Definition at line 3784 of file flow_graph.h.

3784  {
3785  return try_get(v);
3786  }
bool try_get(input_type &v) __TBB_override
Request an item from the sender.
Definition: flow_graph.h:3774

Friends And Related Function Documentation

◆ internal::broadcast_cache

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

Definition at line 3807 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 3808 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 3806 of file flow_graph.h.

Member Data Documentation

◆ my_buffer

template<typename T >
input_type tbb::flow::interface10a::overwrite_node< T >::my_buffer
protected

Definition at line 3848 of file flow_graph.h.

◆ my_buffer_is_valid

template<typename T >
bool tbb::flow::interface10a::overwrite_node< T >::my_buffer_is_valid
protected

Definition at line 3849 of file flow_graph.h.

◆ my_mutex

template<typename T >
spin_mutex tbb::flow::interface10a::overwrite_node< T >::my_mutex
protected

Definition at line 3843 of file flow_graph.h.

◆ my_successors

template<typename T >
internal::broadcast_cache< input_type, null_rw_mutex > tbb::flow::interface10a::overwrite_node< T >::my_successors
protected

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