Generic thread-safe queue with a max capacity.
More...
#include <ETLHelpers.hpp>
|
| ThreadSafeQueue (uint32_t maxSize) |
| Create an instance of the queue.
|
|
void | push (T const &elt) |
| Push element onto the queue.
|
|
void | push (T &&elt) |
| Push element onto the queue.
|
|
T | pop () |
| Pop element from the queue.
|
|
std::optional< T > | tryPop () |
| Attempt to pop an element.
|
|
std::size_t | size () const |
| Get the size of the queue.
|
|
template<typename T>
class etl::ThreadSafeQueue< T >
Generic thread-safe queue with a max capacity.
- Note
- (original note) We can't use a lockfree queue here, since we need the ability to wait for an element to be added or removed from the queue. These waits are blocking calls.
◆ ThreadSafeQueue()
Create an instance of the queue.
- Parameters
-
maxSize | maximum size of the queue. Calls that would cause the queue to exceed this size will block until free space is available. |
◆ pop()
Pop element from the queue.
Note: Will block until queue is non-empty.
- Returns
- Element popped from queue
◆ push() [1/2]
Push element onto the queue.
Note: This method will block until free space is available
- Parameters
-
elt | Element to push onto queue. Ownership is transferred |
◆ push() [2/2]
Push element onto the queue.
Note: This method will block until free space is available.
- Parameters
-
elt | Element to push onto queue |
◆ size()
Get the size of the queue.
- Returns
- The size of the queue
◆ tryPop()
Attempt to pop an element.
- Returns
- Element popped from queue or empty optional if queue was empty
The documentation for this class was generated from the following file: