diff --git a/iceoryx_hoofs/README.md b/iceoryx_hoofs/README.md index 20185846bd..d1299c4608 100644 --- a/iceoryx_hoofs/README.md +++ b/iceoryx_hoofs/README.md @@ -99,7 +99,7 @@ The module structure is a logical grouping. It is replicated for `concurrent` an | class | internal | description | |:----------------------------------:|:--------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -|`FiFo` | i | Single producer, single consumer lock-free FiFo | +|`SpscFifo` | i | Single producer, single consumer lock-free FiFo | |`LockfreeQueue` | | Multi producer, multi consumer lock-free FiFo with ringbuffer like overflow handling | |`MpmcLoFFLi` | i | Lock-free LIFO based index manager (lock-free free list). One building block of our memory manager. After construction it contains the indices {0 ... n} which you can acquire and release. | |`SoFi` | i | Single producer, single consumer lock-free safely overflowing FiFo (SoFi). | @@ -111,7 +111,7 @@ The module structure is a logical grouping. It is replicated for `concurrent` an | Data Structure | Shared Memory usable | Thread-Safe | Lock-Free | Concurrent Producers : Consumers | Bounded Capacity | Data Type Restriction | Use Case | |--------------------------|-----------------------|-------------|-----------|----------------------------------|------------------|-----------------------|-------------------------------------------------------------------------------------------------------------------------| -|`FiFo` | Yes | Yes | Yes | 1:1 | Yes | Copyable | FIFO Data transfer | +|`SpscFifo` | Yes | Yes | Yes | 1:1 | Yes | Copyable | FIFO Data transfer | |`LockfreeQueue` | Yes | Yes | Yes | n:m | Yes | Copyable or Movable | lock-free transfer of arbitrary data between multiple contexts in FIFO order with overflow handling (ringbuffer) | |`MpmcLoFFLi` | Yes | Yes | Yes | n:m | Yes | int32 | manage memory access, LIFO order | |`SoFi` | Yes | Yes | Yes | 1:1 | Yes | Trivially Copyable | lock-free transfer of small data (e.g. pointers) between two contexts in FIFO order with overflow handling (ringbuffer) | diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/fifo.hpp b/iceoryx_hoofs/concurrent/buffer/include/iox/detail/spsc_fifo.hpp similarity index 90% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/fifo.hpp rename to iceoryx_hoofs/concurrent/buffer/include/iox/detail/spsc_fifo.hpp index fd542db789..1765092d28 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/fifo.hpp +++ b/iceoryx_hoofs/concurrent/buffer/include/iox/detail/spsc_fifo.hpp @@ -14,8 +14,9 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CONCURRENT_FIFO_HPP -#define IOX_HOOFS_CONCURRENT_FIFO_HPP + +#ifndef IOX_HOOFS_CONCURRENT_BUFFER_SPSC_FIFO_HPP +#define IOX_HOOFS_CONCURRENT_BUFFER_SPSC_FIFO_HPP #include "iox/optional.hpp" #include "iox/uninitialized_array.hpp" @@ -28,7 +29,7 @@ namespace concurrent { /// @brief single pusher single pop'er thread safe fifo template -class FiFo +class SpscFifo { public: /// @brief pushes a value into the fifo @@ -62,6 +63,6 @@ class FiFo } // namespace concurrent } // namespace iox -#include "iceoryx_hoofs/internal/concurrent/fifo.inl" +#include "iox/detail/spsc_fifo.inl" -#endif // IOX_HOOFS_CONCURRENT_FIFO_HPP +#endif // IOX_HOOFS_CONCURRENT_BUFFER_SPSC_FIFO_HPP diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/fifo.inl b/iceoryx_hoofs/concurrent/buffer/include/iox/detail/spsc_fifo.inl similarity index 81% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/fifo.inl rename to iceoryx_hoofs/concurrent/buffer/include/iox/detail/spsc_fifo.inl index 82e9d76653..1b1688ef51 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/concurrent/fifo.inl +++ b/iceoryx_hoofs/concurrent/buffer/include/iox/detail/spsc_fifo.inl @@ -14,17 +14,18 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CONCURRENT_FIFO_INL -#define IOX_HOOFS_CONCURRENT_FIFO_INL -#include "iceoryx_hoofs/internal/concurrent/fifo.hpp" +#ifndef IOX_HOOFS_CONCURRENT_BUFFER_SPSC_FIFO_INL +#define IOX_HOOFS_CONCURRENT_BUFFER_SPSC_FIFO_INL + +#include "iox/detail/spsc_fifo.hpp" namespace iox { namespace concurrent { template -inline bool FiFo::push(const ValueType& value) noexcept +inline bool SpscFifo::push(const ValueType& value) noexcept { if (is_full()) { @@ -42,31 +43,31 @@ inline bool FiFo::push(const ValueType& value) noexcept } template -inline bool FiFo::is_full() const noexcept +inline bool SpscFifo::is_full() const noexcept { return m_write_pos.load(std::memory_order_relaxed) == m_read_pos.load(std::memory_order_relaxed) + Capacity; } template -inline uint64_t FiFo::size() const noexcept +inline uint64_t SpscFifo::size() const noexcept { return m_write_pos.load(std::memory_order_relaxed) - m_read_pos.load(std::memory_order_relaxed); } template -inline constexpr uint64_t FiFo::capacity() noexcept +inline constexpr uint64_t SpscFifo::capacity() noexcept { return Capacity; } template -inline bool FiFo::empty() const noexcept +inline bool SpscFifo::empty() const noexcept { return m_read_pos.load(std::memory_order_relaxed) == m_write_pos.load(std::memory_order_relaxed); } template -inline optional FiFo::pop() noexcept +inline optional SpscFifo::pop() noexcept { auto currentReadPos = m_read_pos.load(std::memory_order_acquire); bool isEmpty = (currentReadPos == @@ -88,4 +89,4 @@ inline optional FiFo::pop() noexcept } // namespace concurrent } // namespace iox -#endif // IOX_HOOFS_CONCURRENT_FIFO_INL +#endif // IOX_HOOFS_CONCURRENT_BUFFER_SPSC_FIFO_INL diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp index 3c821a0987..5d09e9a0c3 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/variant_queue.hpp @@ -18,8 +18,8 @@ #define IOX_HOOFS_CXX_VARIANT_QUEUE_HPP #include "iceoryx_hoofs/concurrent/resizeable_lockfree_queue.hpp" -#include "iceoryx_hoofs/internal/concurrent/fifo.hpp" #include "iceoryx_hoofs/internal/concurrent/sofi.hpp" +#include "iox/detail/spsc_fifo.hpp" #include "iox/optional.hpp" #include "iox/variant.hpp" @@ -69,7 +69,7 @@ template class VariantQueue { public: - using fifo_t = variant, + using fifo_t = variant, concurrent::SoFi, concurrent::ResizeableLockFreeQueue, concurrent::ResizeableLockFreeQueue>; diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl index a58e071978..9c3269e1c9 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/variant_queue.inl @@ -32,7 +32,7 @@ inline VariantQueue::VariantQueue(const VariantQueueTypes t { case VariantQueueTypes::FiFo_SingleProducerSingleConsumer: { - m_fifo.template emplace>(); + m_fifo.template emplace>(); break; } case VariantQueueTypes::SoFi_SingleProducerSingleConsumer: diff --git a/iceoryx_hoofs/test/moduletests/test_concurrent_fifo.cpp b/iceoryx_hoofs/test/moduletests/test_concurrent_spsc_fifo.cpp similarity index 88% rename from iceoryx_hoofs/test/moduletests/test_concurrent_fifo.cpp rename to iceoryx_hoofs/test/moduletests/test_concurrent_spsc_fifo.cpp index af50187714..07ab32b3eb 100644 --- a/iceoryx_hoofs/test/moduletests/test_concurrent_fifo.cpp +++ b/iceoryx_hoofs/test/moduletests/test_concurrent_spsc_fifo.cpp @@ -15,7 +15,7 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_hoofs/internal/concurrent/fifo.hpp" +#include "iox/detail/spsc_fifo.hpp" #include #include @@ -29,7 +29,7 @@ using namespace iox::concurrent; constexpr uint64_t FIFO_CAPACITY = 10; -class FiFo_Test : public Test +class SpscFifo_Test : public Test { public: void SetUp() override @@ -40,10 +40,10 @@ class FiFo_Test : public Test { } - FiFo sut; + SpscFifo sut; }; -TEST_F(FiFo_Test, SinglePopSinglePush) +TEST_F(SpscFifo_Test, SinglePopSinglePush) { ::testing::Test::RecordProperty("TEST_ID", "57059a17-ec89-42e3-a07c-4a53d0cdcb1d"); EXPECT_THAT(sut.push(25), Eq(true)); @@ -52,14 +52,14 @@ TEST_F(FiFo_Test, SinglePopSinglePush) EXPECT_THAT(result.value(), Eq(25U)); } -TEST_F(FiFo_Test, PopFailsWhenEmpty) +TEST_F(SpscFifo_Test, PopFailsWhenEmpty) { ::testing::Test::RecordProperty("TEST_ID", "0063d54a-e3cb-43f8-ac32-fd0ad94ba7e1"); auto result = sut.pop(); EXPECT_THAT(result.has_value(), Eq(false)); } -TEST_F(FiFo_Test, PushFailsWhenFull) +TEST_F(SpscFifo_Test, PushFailsWhenFull) { ::testing::Test::RecordProperty("TEST_ID", "8d492e83-c0c3-47bd-b745-9f56e20199e9"); for (uint64_t k = 0; k < FIFO_CAPACITY; ++k) @@ -69,7 +69,7 @@ TEST_F(FiFo_Test, PushFailsWhenFull) EXPECT_THAT(sut.push(123), Eq(false)); } -TEST_F(FiFo_Test, IsEmptyWhenPopReturnsNullopt) +TEST_F(SpscFifo_Test, IsEmptyWhenPopReturnsNullopt) { ::testing::Test::RecordProperty("TEST_ID", "81a538c8-f366-4625-8aad-d83ab1d5ecf4"); for (uint64_t k = 0; k < FIFO_CAPACITY; ++k) @@ -85,7 +85,7 @@ TEST_F(FiFo_Test, IsEmptyWhenPopReturnsNullopt) EXPECT_THAT(sut.empty(), Eq(true)); } -TEST_F(FiFo_Test, OverflowTestWithPushPopAlternation) +TEST_F(SpscFifo_Test, OverflowTestWithPushPopAlternation) { ::testing::Test::RecordProperty("TEST_ID", "6ea65156-ca3f-42fc-b199-1119696023c1"); for (uint64_t k = 0; k < 100 * FIFO_CAPACITY; ++k) @@ -97,7 +97,7 @@ TEST_F(FiFo_Test, OverflowTestWithPushPopAlternation) } } -TEST_F(FiFo_Test, OverflowFromFullToEmptyRepetition) +TEST_F(SpscFifo_Test, OverflowFromFullToEmptyRepetition) { ::testing::Test::RecordProperty("TEST_ID", "33a8c03f-5538-46b4-846e-9dec4badab0b"); uint64_t m = 0; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/interface_port_data.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/interface_port_data.hpp index ebf393d648..0a575d0d3c 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/interface_port_data.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/ports/interface_port_data.hpp @@ -17,10 +17,10 @@ #ifndef IOX_POSH_POPO_PORTS_INTERFACE_PORT_DATA_HPP #define IOX_POSH_POPO_PORTS_INTERFACE_PORT_DATA_HPP -#include "iceoryx_hoofs/internal/concurrent/fifo.hpp" #include "iceoryx_posh/capro/service_description.hpp" #include "iceoryx_posh/iceoryx_posh_types.hpp" #include "iceoryx_posh/internal/popo/ports/base_port_data.hpp" +#include "iox/detail/spsc_fifo.hpp" namespace iox { @@ -31,7 +31,7 @@ struct InterfacePortData : public BasePortData InterfacePortData() noexcept = default; InterfacePortData(const RuntimeName_t& runtimeName, const capro::Interfaces interface) noexcept; - concurrent::FiFo m_caproMessageFiFo; + concurrent::SpscFifo m_caproMessageFiFo; bool m_doInitialOfferForward{true}; }; } // namespace popo