18#ifndef IOX_HOOFS_CONCURRENT_LOCKFREE_QUEUE_HPP
19#define IOX_HOOFS_CONCURRENT_LOCKFREE_QUEUE_HPP
21#include "iceoryx_hoofs/cxx/optional.hpp"
22#include "iceoryx_hoofs/internal/concurrent/lockfree_queue/buffer.hpp"
23#include "iceoryx_hoofs/internal/concurrent/lockfree_queue/index_queue.hpp"
34template <
typename ElementType, u
int64_t Capacity>
38 using element_t = ElementType;
61 bool tryPush(ElementType&& value) noexcept;
67 bool tryPush(const ElementType& value) noexcept;
74 iox::cxx::optional<ElementType>
push(const ElementType& value) noexcept;
81 iox::cxx::optional<ElementType>
push(ElementType&& value) noexcept;
86 iox::cxx::optional<ElementType>
pop() noexcept;
101 uint64_t
size() const noexcept;
104 using Queue = IndexQueue<Capacity>;
105 using BufferIndex = typename Queue::value_t;
114 Buffer<ElementType, Capacity, BufferIndex> m_buffer;
116 std::atomic<uint64_t> m_size{0u};
120 template <
typename T>
121 void writeBufferAt(
const BufferIndex&, T&&) noexcept;
124 template <typename T>
125 iox::cxx::optional<ElementType> pushImpl(T&& value) noexcept;
127 cxx::optional<ElementType> readBufferAt(const BufferIndex&) noexcept;
132#include "iceoryx_hoofs/internal/concurrent/lockfree_queue/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
LockFreeQueue() noexcept
creates and initalizes an empty LockFreeQueue
constexpr uint64_t capacity() const noexcept
returns the capacity of the queue
uint64_t size() const noexcept
get the number of stored elements in 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 ...
iox::cxx::optional< ElementType > pop() noexcept
tries to remove value in FIFO order
building block to easily create free function for logging in a library context
Definition lockfree_queue.hpp:29