17#ifndef IOX_HOOFS_CONCURRENT_RESIZEABLE_LOCKFREE_QUEUE_HPP
18#define IOX_HOOFS_CONCURRENT_RESIZEABLE_LOCKFREE_QUEUE_HPP
20#include "iceoryx_hoofs/concurrent/lockfree_queue.hpp"
21#include "iceoryx_hoofs/cxx/type_traits.hpp"
22#include "iceoryx_hoofs/cxx/vector.hpp"
46template <
typename ElementType, u
int64_t MaxCapacity>
53 using element_t = ElementType;
54 static constexpr uint64_t MAX_CAPACITY = MaxCapacity;
87 iox::cxx::optional<ElementType>
push(const ElementType& value) noexcept;
94 iox::cxx::optional<ElementType>
push(ElementType&& value) noexcept;
114 template <typename Function,
115 typename = typename std::enable_if<cxx::is_invocable<Function, ElementType>::value>::type>
116 bool setCapacity(const uint64_t newCapacity, Function&& removeHandler) noexcept;
126 using BufferIndex = typename
Base::BufferIndex;
127 std::atomic<uint64_t> m_capacity{MaxCapacity};
129 std::atomic_flag m_resizeInProgress = ATOMIC_FLAG_INIT;
137 uint64_t increaseCapacity(
const uint64_t toIncrease)
noexcept;
146 template <
typename Function>
147 uint64_t decreaseCapacity(
const uint64_t toDecrease, Function&& removeHandler)
noexcept;
152 bool tryGetUsedIndex(BufferIndex& index)
noexcept;
154 template <
typename T>
161#include "iceoryx_hoofs/internal/concurrent/lockfree_queue/resizeable_lockfree_queue.inl"
implements a lock free queue (i.e. container with FIFO order) of elements of type T with a fixed Capa...
Definition lockfree_queue.hpp:36
bool tryPush(ElementType &&value) noexcept
tries to insert value in FIFO order, moves the value internally
bool empty() const noexcept
check whether the queue is empty
uint64_t size() const noexcept
get the number of stored elements in the queue
iox::cxx::optional< ElementType > pop() noexcept
tries to remove value in FIFO order
implements a lock free queue (i.e. container with FIFO order) of elements of type T with a maximum ca...
Definition resizeable_lockfree_queue.hpp:48
uint64_t capacity() const noexcept
returns the current capacity of the queue
static constexpr uint64_t maxCapacity() noexcept
returns the maximum capacity of the queue
iox::cxx::optional< ElementType > push(const ElementType &value) noexcept
inserts value in FIFO order, always succeeds by removing the oldest value when the queue is detected ...
bool setCapacity(const uint64_t newCapacity, Function &&removeHandler) noexcept
Set the capacity to some value.
Optional implementation from the C++17 standard with C++11. The interface is analog to the C++17 stan...
Definition optional.hpp:69
C++11 compatible vector implementation. We needed to do some adjustments in the API since we do not u...
Definition vector.hpp:39
building block to easily create free function for logging in a library context
Definition lockfree_queue.hpp:29