16 #ifndef IOX_UTILS_CONCURRENT_SOFI_HPP
17 #define IOX_UTILS_CONCURRENT_SOFI_HPP
19 #include "iceoryx_utils/platform/platform_correction.hpp"
44 template <
class ValueType, u
int64_t CapacityValue>
47 static_assert(std::is_trivially_copyable<ValueType>::value,
"SoFi can handle only trivially copyable data types");
52 static_assert(2 <= ATOMIC_INT_LOCK_FREE,
"SoFi is not able to run lock free on this data type");
56 static constexpr uint32_t INTERNAL_SIZE_ADD_ON = 1;
59 static constexpr uint32_t INTERNAL_SOFI_SIZE = CapacityValue + INTERNAL_SIZE_ADD_ON;
100 bool push(
const ValueType& valueOut, ValueType& f_paramOut_r) noexcept;
107 bool pop(ValueType& valueOut) noexcept;
127 template <
typename Verificator_T>
128 bool popIf(ValueType& valueOut,
const Verificator_T& verificator) noexcept;
135 bool empty()
const noexcept;
150 uint64_t
size()
const noexcept;
153 ValueType m_data[INTERNAL_SOFI_SIZE];
154 uint64_t m_size = INTERNAL_SOFI_SIZE;
158 std::atomic<uint64_t> m_readPosition{0u};
159 std::atomic<uint64_t> m_writePosition{0u};
165 #include "iceoryx_utils/internal/concurrent/sofi.inl"
Thread safe producer and consumer queue with a safe overflowing behavior. SoFi is designed in a FIFO ...
Definition: sofi.hpp:46
bool empty() const noexcept
returns true if sofi is empty, otherwise false
Definition: sofi.inl:67
bool pop(ValueType &valueOut) noexcept
pop the oldest element
Definition: sofi.inl:87
SoFi() noexcept
default constructor which constructs an empty sofi
Definition: sofi.inl:24
uint64_t size() const noexcept
returns the current size of sofi
Definition: sofi.inl:35
bool popIf(ValueType &valueOut, const Verificator_T &verificator) noexcept
conditional pop call to provide an alternative for a peek and pop approach. If the verificator return...
Definition: sofi.inl:94
bool push(const ValueType &valueOut, ValueType &f_paramOut_r) noexcept
pushs an element into sofi. if sofi is full the oldest data will be returned and the pushed element i...
Definition: sofi.inl:144
uint64_t capacity() const noexcept
returns the capacity of sofi
Definition: sofi.inl:29
bool setCapacity(const uint64_t newSize) noexcept
resizes sofi
Definition: sofi.inl:50
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28