Intel(R) Threading Building Blocks Doxygen Documentation version 4.2.3
Loading...
Searching...
No Matches
tbb::flow::interface11::overwrite_node< T > Class Template Reference

#include <flow_graph.h>

Inheritance diagram for tbb::flow::interface11::overwrite_node< T >:
Collaboration diagram for tbb::flow::interface11::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::interface11::internal::untyped_receiver
typedef untyped_sender predecessor_type
 The predecessor type for this node.
 
- Public Types inherited from tbb::flow::interface11::internal::untyped_sender
typedef untyped_receiver successor_type
 The successor type for this node.
 

Public Member Functions

__TBB_NOINLINE_SYM overwrite_node (graph &g)
 
__TBB_NOINLINE_SYM overwrite_node (const overwrite_node &src)
 Copy constructor; doesn't take anything from src; default won't work.
 
 ~overwrite_node ()
 
bool register_successor (successor_type &s) __TBB_override
 Add a new successor to this node.
 
bool remove_successor (successor_type &s) __TBB_override
 Removes a successor from this node.
 
bool try_get (input_type &v) __TBB_override
 Request an item from the sender.
 
bool try_reserve (T &v) __TBB_override
 Reserves an item.
 
bool try_release () __TBB_override
 Releases the reserved item.
 
bool try_consume () __TBB_override
 Consumes the reserved item.
 
bool is_valid ()
 
void clear ()
 
- Public Member Functions inherited from tbb::flow::interface11::graph_node
 graph_node (graph &g)
 
virtual ~graph_node ()
 
- Public Member Functions inherited from tbb::flow::interface11::receiver< T >
bool try_put (const typename internal::async_helpers< T >::filtered_type &t)
 Put an item to the receiver.
 
bool try_put (const typename internal::async_helpers< T >::async_type &t)
 
- Public Member Functions inherited from tbb::flow::interface11::internal::untyped_receiver
virtual ~untyped_receiver ()
 Destructor.
 
template<typename X >
bool try_put (const X &t)
 Put an item to the receiver.
 
virtual bool register_predecessor (predecessor_type &)
 Add a predecessor to the node.
 
virtual bool remove_predecessor (predecessor_type &)
 Remove a predecessor from the node.
 
virtual bool try_get (T &)
 Request an item from the sender.
 
virtual bool try_reserve (T &)
 Reserves an item in the sender.
 
- Public Member Functions inherited from tbb::flow::interface11::internal::untyped_sender
virtual ~untyped_sender ()
 
virtual bool register_successor (successor_type &r)=0
 Add a new successor to this node.
 
virtual bool remove_successor (successor_type &r)=0
 Removes a successor from this node.
 
virtual bool try_release ()
 Releases the reserved item.
 
virtual bool try_consume ()
 Consumes the reserved item.
 

Protected Member Functions

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

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::interface11::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
 

Additional Inherited Members

- Public Attributes inherited from tbb::flow::interface11::receiver< T >
__TBB_DEPRECATED typedef T input_type
 The input type of this receiver.
 
__TBB_DEPRECATED typedef internal::async_helpers< T >::filtered_type filtered_type
 
- Public Attributes inherited from tbb::flow::interface11::sender< T >
__TBB_DEPRECATED typedef T output_type
 The output type of this sender.
 
__TBB_DEPRECATED typedef internal::async_helpers< T >::filtered_type filtered_type
 

Detailed Description

template<typename T>
class tbb::flow::interface11::overwrite_node< T >

Definition at line 4410 of file flow_graph.h.

Member Typedef Documentation

◆ input_type

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

Definition at line 4412 of file flow_graph.h.

◆ output_type

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

Definition at line 4413 of file flow_graph.h.

◆ predecessor_type

template<typename T >
typedef receiver<input_type>::predecessor_type tbb::flow::interface11::overwrite_node< T >::predecessor_type

Definition at line 4414 of file flow_graph.h.

◆ successor_type

template<typename T >
typedef sender<output_type>::successor_type tbb::flow::interface11::overwrite_node< T >::successor_type

Definition at line 4415 of file flow_graph.h.

Constructor & Destructor Documentation

◆ overwrite_node() [1/2]

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

Definition at line 4423 of file flow_graph.h.

4423 : graph_node(g), my_buffer_is_valid(false) {
4424 my_successors.set_owner( this );
4425 tbb::internal::fgt_node( CODEPTR(), tbb::internal::FLOW_OVERWRITE_NODE, &this->my_graph,
4426 static_cast<receiver<input_type> *>(this), static_cast<sender<output_type> *>(this) );
4427 }
#define CODEPTR()
static void fgt_node(void *, string_index, void *, void *)
internal::broadcast_cache< input_type, null_rw_mutex > my_successors

References CODEPTR, and tbb::internal::fgt_node().

Here is the call graph for this function:

◆ overwrite_node() [2/2]

template<typename T >
__TBB_NOINLINE_SYM tbb::flow::interface11::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 4437 of file flow_graph.h.

4437 :
4438 graph_node(src.my_graph), receiver<T>(), sender<T>(), my_buffer_is_valid(false)
4439 {
4440 my_successors.set_owner( this );
4441 tbb::internal::fgt_node( CODEPTR(), tbb::internal::FLOW_OVERWRITE_NODE, &this->my_graph,
4442 static_cast<receiver<input_type> *>(this), static_cast<sender<output_type> *>(this) );
4443 }

References CODEPTR, and tbb::internal::fgt_node().

Here is the call graph for this function:

◆ ~overwrite_node()

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

Definition at line 4445 of file flow_graph.h.

4445{}

Member Function Documentation

◆ clear()

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

Definition at line 4560 of file flow_graph.h.

4560 {
4561 spin_mutex::scoped_lock l( my_mutex );
4562 my_buffer_is_valid = false;
4563 }

◆ graph_reference()

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

Implements tbb::flow::interface11::internal::untyped_receiver.

Definition at line 4583 of file flow_graph.h.

4583 {
4584 return my_graph;
4585 }

◆ is_valid()

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

Definition at line 4555 of file flow_graph.h.

4555 {
4556 spin_mutex::scoped_lock l( my_mutex );
4557 return my_buffer_is_valid;
4558 }

◆ register_successor()

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

Add a new successor to this node.

Implements tbb::flow::interface11::internal::untyped_sender.

Definition at line 4453 of file flow_graph.h.

4453 {
4454 spin_mutex::scoped_lock l( my_mutex );
4456 // We have a valid value that must be forwarded immediately.
4457 bool ret = s.try_put( my_buffer );
4458 if ( ret ) {
4459 // We add the successor that accepted our put
4460 my_successors.register_successor( s );
4461 } else {
4462 // In case of reservation a race between the moment of reservation and register_successor can appear,
4463 // because failed reserve does not mean that register_successor is not ready to put a message immediately.
4464 // We have some sort of infinite loop: reserving node tries to set pull state for the edge,
4465 // but overwrite_node tries to return push state back. That is why we have to break this loop with task creation.
4466 task *rtask = new ( task::allocate_additional_child_of( *( my_graph.root_task() ) ) )
4467 register_predecessor_task( *this, s );
4469 }
4470 } else {
4471 // No valid value yet, just add as successor
4472 my_successors.register_successor( s );
4473 }
4474 return true;
4475 }
void const char const char int ITT_FORMAT __itt_group_sync s
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
void spawn_in_graph_arena(tbb::flow::interface10::graph &g, tbb::task &arena_task)
Spawns a task inside graph arena.
bool is_graph_active(tbb::flow::interface10::graph &g)
__TBB_DEPRECATED tbb::task * root_task()
Returns the root task of the graph.

References s.

◆ remove_successor()

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

Removes a successor from this node.

Implements tbb::flow::interface11::internal::untyped_sender.

Definition at line 4477 of file flow_graph.h.

4477 {
4478 spin_mutex::scoped_lock l( my_mutex );
4479 my_successors.remove_successor(s);
4480 return true;
4481 }

References s.

◆ reset_node()

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

Implements tbb::flow::interface11::graph_node.

Definition at line 4613 of file flow_graph.h.

4613 {
4614 my_buffer_is_valid = false;
4615 if (f&rf_clear_edges) {
4616 my_successors.clear();
4617 }
4618 }

References tbb::flow::interface11::rf_clear_edges.

◆ reset_receiver()

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

put receiver back in initial state

Implements tbb::flow::interface11::internal::untyped_receiver.

Definition at line 4611 of file flow_graph.h.

4611{}

◆ try_consume()

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

Consumes the reserved item.

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

Definition at line 4553 of file flow_graph.h.

4553{ return true; }

◆ try_get()

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

Request an item from the sender.

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

Definition at line 4535 of file flow_graph.h.

4535 {
4536 spin_mutex::scoped_lock l( my_mutex );
4537 if ( my_buffer_is_valid ) {
4538 v = my_buffer;
4539 return true;
4540 }
4541 return false;
4542 }

◆ try_put_task()

template<typename T >
task * tbb::flow::interface11::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::interface11::receiver< T >.

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

Definition at line 4570 of file flow_graph.h.

4570 {
4571 spin_mutex::scoped_lock l( my_mutex );
4572 return try_put_task_impl(v);
4573 }
task * try_put_task_impl(const input_type &v)

◆ try_put_task_impl()

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

Definition at line 4575 of file flow_graph.h.

4575 {
4576 my_buffer = v;
4577 my_buffer_is_valid = true;
4578 task * rtask = my_successors.try_put_task(v);
4579 if (!rtask) rtask = SUCCESSFULLY_ENQUEUED;
4580 return rtask;
4581 }

◆ try_release()

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

Releases the reserved item.

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

Definition at line 4550 of file flow_graph.h.

4550{ return true; }

◆ try_reserve()

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

Reserves an item.

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

Definition at line 4545 of file flow_graph.h.

4545 {
4546 return try_get(v);
4547 }
bool try_get(input_type &v) __TBB_override
Request an item from the sender.

Friends And Related Symbol Documentation

◆ internal::broadcast_cache

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

Definition at line 4568 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 4569 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 4567 of file flow_graph.h.

Member Data Documentation

◆ my_buffer

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

Definition at line 4609 of file flow_graph.h.

◆ my_buffer_is_valid

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

Definition at line 4610 of file flow_graph.h.

◆ my_mutex

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

Definition at line 4604 of file flow_graph.h.

◆ my_successors

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

Definition at line 4605 of file flow_graph.h.


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

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