iceoryx_hoofs 2.0.5
|
wrapper of multiple fifo's More...
#include <iceoryx_hoofs/cxx/variant_queue.hpp>
Public Types | |
using | fifo_t = variant< concurrent::FiFo< ValueType, Capacity >, concurrent::SoFi< ValueType, Capacity >, concurrent::ResizeableLockFreeQueue< ValueType, Capacity >, concurrent::ResizeableLockFreeQueue< ValueType, Capacity > > |
Public Member Functions | |
VariantQueue (const VariantQueueTypes type) noexcept | |
Constructor of a VariantQueue. | |
optional< ValueType > | push (const ValueType &value) noexcept |
pushs an element into the fifo | |
optional< ValueType > | pop () noexcept |
pops an element from the fifo | |
bool | empty () const noexcept |
returns true if empty otherwise true | |
uint64_t | size () noexcept |
get the current size of the queue. Caution, another thread can have changed the size just after reading it | |
bool | setCapacity (const uint64_t newCapacity) noexcept |
set the capacity of the queue | |
uint64_t | capacity () const noexcept |
get the capacity of the queue. | |
fifo_t & | getUnderlyingFiFo () noexcept |
returns reference to the underlying fifo | |
wrapper of multiple fifo's
[in] | ValueType | type which should be stored |
[in] | Capacity | capacity of the underlying fifo cxx::VariantQueue<int, 5> nonOverflowingQueue(cxx::VariantQueueTypes::FiFo_SingleProducerSingleConsumer);
cxx::VariantQueue<int, 5> overflowingQueue(cxx::VariantQueueTypes::SoFi_SingleProducerSingleConsumer);
// overflow case
auto status = nonOverflowingQueue.push(123);
if ( !status ) {
std::cout << "queue is full" << std::endl;
}
auto overriddenElement = overflowingQueue.push(123);
if ( overriddenElement->has_value() ) {
std::cout << "element " << overriddenElement->value() << " was overridden\n";
}
|
|
noexcept |
Constructor of a VariantQueue.
[in] | type | type of the underlying queue |
|
noexcept |
get the capacity of the queue.
|
noexcept |
returns reference to the underlying fifo
|
noexcept |
pops an element from the fifo
|
noexcept |
pushs an element into the fifo
[in] | value | value which should be added in the fifo |
|
noexcept |
set the capacity of the queue
[in] | newCapacity | valid values are 0 < newCapacity < MAX_SUBSCRIBER_QUEUE_CAPACITY |
|
noexcept |
get the current size of the queue. Caution, another thread can have changed the size just after reading it