Intel® oneAPI Threading Building Blocks Developer Guide and API Reference
queue_node
[flow_graph.queue_node]
A node that forwards messages in a first-in first-out (FIFO) order.
// Defined in header <oneapi/tbb/flow_graph.h>
namespace oneapi {
namespace tbb {
namespace flow {
template <typename T >
class queue_node : public graph_node, public receiver<T>, public sender<T> {
public:
explicit queue_node( graph &g );
queue_node( const queue_node &src );
~queue_node();
// Preview feature: Helper Functions for Expressing Graphs
explicit queue_node(decltype(follows(...)));
explicit queue_node(decltype(precedes(...)));
bool try_put( const T &v );
bool try_get( T &v );
// Preview feature: Waiting for Single Message
bool try_put_and_wait( const T &v );
};
} // namespace flow
} // namespace tbb
} // namespace oneapi
Requirements:
The type T must meet the CopyConstructible requirements from [copyconstructible] and CopyAssignable requirements from [copyassignable] ISO C++ Standard sections.
queue_node forwards messages in a FIFO order to a single successor in its successor set.
queue_node is a graph_node, receiver and sender.
queue_node has a buffering and single-pushproperties.
Member functions
explicitqueue_node(graph&g)
Constructs an empty queue_node that belongs to the graph g.
queue_node(constqueue_node&src)
Constructs an empty queue_node that belongs to the same graph g as src. Any intermediate state of src, including its links to predecessors and successors, is not copied.
booltry_put(constT&v)
Adds v to the set of items managed by the node, and tries forwarding the least recently added item to a successor.
Returns: true.
booltry_get(T&v)
Returns: true if an item can be taken from the node and assigned to v. Returns false if there is no item currently in the queue_node or if the node is reserved.
Preview Features
The following preview features extend the queue_node API:
Helper Functions for Expressing Graphs - allows queue_node to be constructed as a successor or a predecessor of the set of nodes.
Waiting for Single Message in Flow Graph - allows to put messages to queue_node and wait for all related work to complete.
Example
Usage scenario is similar to buffer_node except that messages are passed in first-in first-out (FIFO) order.