Template Class concurrent_queue¶
Defined in File concurrent_queue.hpp
Class Documentation¶
-
template<typename
T, queue_typeconc_type= queue_type::multi_prod_multi_cons>
classconcore::v1::concurrent_queue¶ Concurrent double-ended queue implementation.
Based on the conc_type parameter, this can be:
single-producer, single-consumer
single-producer, multi-consumer
multi-producer, single-consumer
multi-producer, multi-consumer
- Template Parameters
T: The type of elements to storeconc_type: The expected concurrency for the queue
Note, that the implementation for some of these alternatives might coincide.
The queue, has 2 ends:
the back: where new element can be added
the front: from which elements can be extracted
The queue has only 2 operations corresponding to pushing new elements into the queue and popping elements out of the queue.
Public Functions
-
concurrent_queue() = default¶ Default constructor. Creates a valid empty queue.
-
~concurrent_queue() = default¶ Destructor.
-
concurrent_queue(const concurrent_queue&) = delete¶ Copy constructor is DISABLED.
-
const concurrent_queue &
operator=(const concurrent_queue&) = delete¶ Copy assignment is DISABLED.
-
concurrent_queue(concurrent_queue&&) = default¶ Move constructor.
-
concurrent_queue &
operator=(concurrent_queue&&) = default¶ Move assignment.
-
void
push(T &&elem)¶ Pushes one element in the back of the queue.
This ensures that is thread-safe with respect to the chosen queue_type concurrency policy.
- Parameters
elem: The element to be added to the queue
- See
-
bool
try_pop(T &elem)¶ Try to pop one element from the front of the queue.
If the queue is empty, this will return false and not touch the given parameter. If the queue is not empty, it will extract the element from the front of the queue and store it in the given parameter.
- Return
True if an element was popped; false otherwise.
- Parameters
elem: [out] Location where to put the popped element
This ensures that is thread-safe with respect to the chosen queue_type concurrency policy.
- See