17 #ifndef IOX_UTILS_CONCURRENT_LOCKFREE_QUEUE_HPP
18 #define IOX_UTILS_CONCURRENT_LOCKFREE_QUEUE_HPP
20 #include "iceoryx_utils/cxx/optional.hpp"
21 #include "iceoryx_utils/internal/concurrent/lockfree_queue/buffer.hpp"
22 #include "iceoryx_utils/internal/concurrent/lockfree_queue/index_queue.hpp"
33 template <
typename ElementType, u
int64_t Capacity>
37 using element_t = ElementType;
54 constexpr uint64_t
capacity()
const noexcept;
60 bool tryPush(ElementType&& value) noexcept;
66 bool tryPush(
const ElementType& value) noexcept;
93 bool empty()
const noexcept;
100 uint64_t
size()
const noexcept;
104 using BufferIndex =
typename Queue::value_t;
115 std::atomic<uint64_t> m_size{0u};
119 template <
typename T>
120 void writeBufferAt(
const BufferIndex&, T&&);
123 template <
typename T>
131 #include "iceoryx_utils/internal/concurrent/lockfree_queue/lockfree_queue.inl"
lockfree queue capable of storing indices 0,1,... Capacity-1
Definition: index_queue.hpp:40
implements a lock free queue (i.e. container with FIFO order) of elements of type T with a fixed Capa...
Definition: lockfree_queue.hpp:35
bool tryPush(ElementType &&value) noexcept
tries to insert value in FIFO order, moves the value internally
Definition: lockfree_queue.inl:56
bool empty() const noexcept
check whether the queue is empty
Definition: lockfree_queue.inl:140
LockFreeQueue() noexcept
creates and initalizes an empty LockFreeQueue
Definition: lockfree_queue.inl:26
constexpr uint64_t capacity() const noexcept
returns the capacity of the queue
Definition: lockfree_queue.inl:33
uint64_t size() const noexcept
get the number of stored elements in the queue
Definition: lockfree_queue.inl:146
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 ...
Definition: lockfree_queue.inl:111
iox::cxx::optional< ElementType > pop() noexcept
tries to remove value in FIFO order
Definition: lockfree_queue.inl:123
Optional implementation from the C++17 standard with C++11. The interface is analog to the C++17 stan...
Definition: optional.hpp:63
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28