Template Class TriggerQueue
Defined in File trigger_queue.hpp
Class Documentation
-
template<typename T, uint64_t Capacity, template<typename, uint64_t> class QueueType>
class TriggerQueue TriggerQueue is behaves exactly like a normal queue (fifo) except that this queue is threadsafe and offers a blocking push which blocks the the caller until the queue has space for at least one element which can be pushed.
Public Functions
-
bool push(const T &in) noexcept
Pushs an element into the trigger queue. If the queue is full it blocks until there is space again. If in the meantime destroy() was called the block is released and push returns false.
-
cxx::optional<T> pop() noexcept
If the queue already contains an element it writes the contents of that element in out and returns true, otherwise false.
- Returns:
if an element could be removed the optional contains it, otherwise when the queue is empty the optional is empty
-
bool empty() const noexcept
Returns true if the queue is empty, otherwise false.
-
uint64_t size() const noexcept
Returns the number of elements which are currently in the queue.
-
void destroy() noexcept
when someone is waiting in push since the queue is full it unblocks push. after that call it is impossible to push elements.
-
bool setCapacity(const uint64_t capacity) noexcept
resizes the queue.
- Returns:
true if resize was successful otherwise false
Public Static Functions
-
static constexpr uint64_t capacity() noexcept
Returns the capacity of the trigger queue.
-
bool push(const T &in) noexcept