Skip to content

Latest commit

 

History

History
101 lines (64 loc) · 2.92 KB

overwrite_node_cls.rst

File metadata and controls

101 lines (64 loc) · 2.92 KB

overwrite_node

[flow_graph.overwrite_node]

A node that is a buffer of a single item that can be overwritten.

// Defined in header <oneapi/tbb/flow_graph.h>

namespace oneapi {
namespace tbb {
namespace flow {

    template<typename T>
    class overwrite_node : public graph_node, public receiver<T>, public sender<T> {
    public:
        explicit overwrite_node( graph &g );
        overwrite_node( const overwrite_node &src );
        ~overwrite_node();

        bool try_put( const T &v );
        bool try_get( T &v );

        bool is_valid( );
        void clear( );
    };

} // namespace flow
} // namespace tbb
} // namespace oneapi

Requirements:

  • The type T must meet the DefaultConstructible requirements from [defaultconstructible] and CopyAssignable requirements from [copyassignable] ISO C++ Standard sections.

This type of node buffers a single item of type T. The value is initially invalid. Gets from the node are non-destructive.

overwrite_node is a graph_node, receiver<T> and sender<T>.

overwrite_node has a buffering and broadcast-push properties <forwarding_and_buffering>.

overwrite_node allows overwriting its single item buffer.

Member functions

oneapi::tbb::flow::overwrite_node

Examples

The example demonstrates overwrite_node as a single-value storage that might be updated. Data can be accessed with direct try_get() call.

overwrite_node supports reserving join_node as its successor. See the example in the example section of write_once_node <write_once_node_cls>.