Concurrent queue.
More...
#include <sirius/utils/concurrent_queue.h>
template<typename T>
class sirius::utils::ConcurrentQueue< T >
Concurrent queue.
ConcurrentQueue is a basic thread safe implementation of a queue. ConcurrentQueue has a limited size. Push and Pop methods can be used in a multi-threaded context.
This implementation is inspired by https://juanchopanzacpp.wordpress.com/2013/02/26/concurrent-queue-c11
- Warning
- Push and Pop methods may block.
◆ ConcurrentQueue() [1/3]
Instanciate a concurrent queue with a maximum size.
The queue is active after instantiation
- Parameters
-
max_queue_size | limit the queue size |
◆ ~ConcurrentQueue()
◆ ConcurrentQueue() [2/3]
◆ ConcurrentQueue() [3/3]
◆ Activate()
Activate the queue.
The queue will be able to receive new elements
◆ CanPop()
Elements can be popped from the queue.
- Returns
- boolean
◆ Deactivate()
Deactivate the queue.
The queue will not be able to receive new elements
◆ DeactivateAndClear()
Deactivate the queue and clear its content.
The queue will not be able to receive new elements and its content will be erased
◆ Empty()
Queue is empty.
- Returns
- true if queue is empty
◆ IsActive()
Can the queue be filled with new elements.
- Returns
- true if the queue is still active
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ Pop()
Pop an element from the queue.
- Parameters
-
- Returns
- An available element from the queue
- Warning
- This method may block until there is an element to pop
-
If no element is available and the queue is not active, this method returns a default constructed element and ec is set
◆ Push()
Push an element in the queue.
- Parameters
-
element | to push to the queue |
ec | return status |
- Warning
- This method may block until there is an available spot
-
If the queue is not active, the element will be dropped and ec is set
◆ Size()
Get queue size.
- Returns
- Queue size
The documentation for this class was generated from the following file: