From ecabee3de02d6bef2ea17b2e05a558076c6eab5d Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Mon, 7 Jun 2021 23:00:24 +0200 Subject: [PATCH 1/8] iox-#842 Use `@copydoc` instead of `@brief Implementation of` Signed-off-by: Mathias Kraus --- .../memory/mempool_collection_memory_block.hpp | 17 ++++++++--------- .../mempool_segment_manager_memory_block.hpp | 17 ++++++++--------- .../roudi/memory/port_pool_memory_block.hpp | 17 ++++++++--------- .../roudi/memory/generic_memory_block.hpp | 11 ++++++----- .../roudi/memory/posix_shm_memory_provider.hpp | 11 ++++------- 5 files changed, 34 insertions(+), 39 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp index c8540d6af3..da6b369f97 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp @@ -45,21 +45,20 @@ class MemPoolCollectionMemoryBlock final : public MemoryBlock MemPoolCollectionMemoryBlock& operator=(const MemPoolCollectionMemoryBlock&) = delete; MemPoolCollectionMemoryBlock& operator=(MemPoolCollectionMemoryBlock&&) = delete; - /// @brief Implementation of MemoryBlock::size - /// @return the size of type T + /// @copydoc MemoryBlock::size + /// @note The size for all the MemPools uint64_t size() const noexcept override; - /// @brief Implementation of MemoryBlock::alignment - /// @return the alignment of type T + /// @copydoc MemoryBlock::alignment + /// @note The memory alignment for the MemPools uint64_t alignment() const noexcept override; - /// @brief Implementation of MemoryBlock::memoryAvailable - /// This will create the MemPools - /// @param [in] memory pointer to a valid memory location to place the mempools + /// @copydoc MemoryBlock::memoryAvailable + /// @note This will create the MemPools at the location `memory` points to void memoryAvailable(void* memory) noexcept override; - /// @brief Implementation of MemoryBlock::destroy - /// This will clean up the MemPools + /// @copydoc MemoryBlock::destroy + /// @note This will clean up the MemPools void destroy() noexcept override; /// @brief This function enables the access to the MemoryManager for the MemPools diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp index 52e9ec5225..7d76f21162 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp @@ -40,21 +40,20 @@ class MemPoolSegmentManagerMemoryBlock : public MemoryBlock MemPoolSegmentManagerMemoryBlock& operator=(const MemPoolSegmentManagerMemoryBlock&) = delete; MemPoolSegmentManagerMemoryBlock& operator=(MemPoolSegmentManagerMemoryBlock&&) = delete; - /// @brief Implementation of MemoryBlock::size - /// @return the size of for SegmentManager + /// @copydoc MemoryBlock::size + /// @note the size of for SegmentManager uint64_t size() const noexcept override; - /// @brief Implementation of MemoryBlock::alignment - /// @return the memory alignment for SegmentManager + /// @copydoc MemoryBlock::alignment + /// @note The memory alignment for SegmentManager uint64_t alignment() const noexcept override; - /// @brief Implementation of MemoryBlock::memoryAvailable - /// This will create the SegmentManager - /// @param [in] memory pointer to a valid memory location to place the mempools + /// @copydoc MemoryBlock::memoryAvailable + /// @note This will create the SegmentManager at the location `memory` points to void memoryAvailable(void* memory) noexcept override; - /// @brief Implementation of MemoryBlock::destroy - /// This will clean up the SegmentManager + /// @copydoc MemoryBlock::destroy + /// @note This will clean up the SegmentManager void destroy() noexcept override; /// @brief This function enables the access to the SegmentManager diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp index 2cbd6a2802..8abe44de73 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp @@ -40,21 +40,20 @@ class PortPoolMemoryBlock : public MemoryBlock PortPoolMemoryBlock& operator=(const PortPoolMemoryBlock&) = delete; PortPoolMemoryBlock& operator=(PortPoolMemoryBlock&&) = delete; - /// @brief Implementation of MemoryBlock::size - /// @return the size of for all the ports + /// @copydoc MemoryBlock::size + /// @note The size of for all the ports uint64_t size() const noexcept override; - /// @brief Implementation of MemoryBlock::alignment - /// @return the memory alignment for the ports + /// @copydoc MemoryBlock::alignment + /// @note The memory alignment for the ports uint64_t alignment() const noexcept override; - /// @brief Implementation of MemoryBlock::memoryAvailable - /// This will create the ports - /// @param [in] memory pointer to a valid memory location to place the mempools + /// @copydoc MemoryBlock::memoryAvailable + /// @note This will create the ports at the location `memory` points to void memoryAvailable(void* memory) noexcept override; - /// @brief Implementation of MemoryBlock::destroy - /// This will clean up the ports + /// @copydoc MemoryBlock::destroy + /// @note This will clean up the ports void destroy() noexcept override; /// @brief This function enables the access to the PortPool diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp index c4bbdf9fdf..fde181c933 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp @@ -41,15 +41,16 @@ class GenericMemoryBlock final : public MemoryBlock GenericMemoryBlock& operator=(const GenericMemoryBlock&) = delete; GenericMemoryBlock& operator=(GenericMemoryBlock&&) = delete; - /// @brief Implementation of MemoryBlock::size - /// @return the size of type T + /// @copydoc MemoryBlock::size() + /// @note The size of the underlying type T uint64_t size() const noexcept override; - /// @brief Implementation of MemoryBlock::alignment - /// @return the alignment of type T + /// @copydoc MemoryBlock::alignment + /// @note The alignment of the underlying type T uint64_t alignment() const noexcept override; - /// @brief Implementation of MemoryBlock::destroy + /// @copydoc MemoryBlock::destroy + /// @note This will destroy the underlying type T void destroy() noexcept override; /// @brief A new element is constructed by forwarding the arguments to the constructor of T. If the MemoryBlock has diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp index 2ffa179303..40469e1d0b 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp @@ -51,15 +51,12 @@ class PosixShmMemoryProvider : public MemoryProvider PosixShmMemoryProvider& operator=(const PosixShmMemoryProvider&) = delete; protected: - /// @brief Implementation of MemoryProvider::createMemory - /// @param [in] size is the size in bytes for the requested memory, the size should already be calculated according - /// to the alignment requirements - /// @param [in] alignment the required alignment for the memory - /// @return the pointer of the begin of the created memory, nullptr if the memory could not be created + /// @copydoc MemoryProvider::createMemory + /// @note This creates and maps a POSIX shared memory to the address space of the application cxx::expected createMemory(const uint64_t size, const uint64_t alignment) noexcept; - /// @brief Implementation of MemoryProvider::destroyMemory - /// @return a MemoryProviderError if the destruction failed, otherwise success + /// @copydoc MemoryProvider::destroyMemory + /// @note This closes and unmaps a POSIX shared memory cxx::expected destroyMemory() noexcept; private: From 2e5a92f78eee818ba855cfbc35bb75b75a5cbec9 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 9 Jun 2021 14:54:44 +0200 Subject: [PATCH 2/8] iox-#842 Make dtor of MemoryProvider and MemoryBlock virtual Signed-off-by: Mathias Kraus --- iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp | 1 + .../include/iceoryx_posh/roudi/memory/memory_provider.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp index 5882198998..08319a3bdc 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp @@ -34,6 +34,7 @@ class MemoryBlock public: MemoryBlock() noexcept = default; + virtual ~MemoryBlock() = default; /// @note this is intentional not movable/copyable, since a pointer to the memory block is registered at a /// MemoryProvider and therefore an instance of a MemoryBlock must be pinned to memory diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_provider.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_provider.hpp index 3256a38321..8b5c26ad24 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_provider.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_provider.hpp @@ -72,7 +72,7 @@ class MemoryProvider public: MemoryProvider() noexcept = default; - ~MemoryProvider() noexcept; + virtual ~MemoryProvider() noexcept; /// @note this is intentional not movable/copyable, since a pointer to the memory provider is registered at the /// RouDiMemoryManager and therefore an instance of a MemoryProvider must be pinned to memory From 012068983d5ee04800449182e4af837ac6a9c988 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 9 Jun 2021 15:01:16 +0200 Subject: [PATCH 3/8] iox-#842 Use cxx::not_null for MemoryBlock::memoryAvailable parameter Signed-off-by: Mathias Kraus --- .../internal/roudi/memory/mempool_collection_memory_block.hpp | 2 +- .../roudi/memory/mempool_segment_manager_memory_block.hpp | 2 +- .../internal/roudi/memory/port_pool_memory_block.hpp | 2 +- .../include/iceoryx_posh/roudi/memory/memory_block.hpp | 3 ++- iceoryx_posh/source/roudi/memory/memory_block.cpp | 2 +- .../source/roudi/memory/mempool_collection_memory_block.cpp | 2 +- .../roudi/memory/mempool_segment_manager_memory_block.cpp | 2 +- iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp | 2 +- iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp | 4 ++-- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp index da6b369f97..37839cd892 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp @@ -55,7 +55,7 @@ class MemPoolCollectionMemoryBlock final : public MemoryBlock /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the MemPools at the location `memory` points to - void memoryAvailable(void* memory) noexcept override; + void memoryAvailable(cxx::not_null memory) noexcept override; /// @copydoc MemoryBlock::destroy /// @note This will clean up the MemPools diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp index 7d76f21162..2d1b1f85f3 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp @@ -50,7 +50,7 @@ class MemPoolSegmentManagerMemoryBlock : public MemoryBlock /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the SegmentManager at the location `memory` points to - void memoryAvailable(void* memory) noexcept override; + void memoryAvailable(cxx::not_null memory) noexcept override; /// @copydoc MemoryBlock::destroy /// @note This will clean up the SegmentManager diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp index 8abe44de73..0e292a7307 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp @@ -50,7 +50,7 @@ class PortPoolMemoryBlock : public MemoryBlock /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the ports at the location `memory` points to - void memoryAvailable(void* memory) noexcept override; + void memoryAvailable(cxx::not_null memory) noexcept override; /// @copydoc MemoryBlock::destroy /// @note This will clean up the ports diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp index 08319a3bdc..552595506e 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp @@ -16,6 +16,7 @@ #ifndef IOX_POSH_ROUDI_MEMORY_MEMORY_BLOCK_HPP #define IOX_POSH_ROUDI_MEMORY_MEMORY_BLOCK_HPP +#include "iceoryx_hoofs/cxx/helplets.hpp" #include "iceoryx_hoofs/cxx/optional.hpp" #include @@ -60,7 +61,7 @@ class MemoryBlock /// @brief This function is called once the memory is available and is therefore the earliest possibility to use the /// memory. /// @param [in] memory pointer to a valid memory block, the same one that the memory() member function would return - virtual void memoryAvailable(void* memory) noexcept; + virtual void memoryAvailable(cxx::not_null memory) noexcept; /// @brief This function provides the pointer to the requested memory. /// @return an optional pointer to a memory block with the requested size and alignment if the memory is available, diff --git a/iceoryx_posh/source/roudi/memory/memory_block.cpp b/iceoryx_posh/source/roudi/memory/memory_block.cpp index c48fba9d1e..52c4712793 100644 --- a/iceoryx_posh/source/roudi/memory/memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/memory_block.cpp @@ -21,7 +21,7 @@ namespace iox { namespace roudi { -void MemoryBlock::memoryAvailable(void* memory IOX_MAYBE_UNUSED) noexcept +void MemoryBlock::memoryAvailable(cxx::not_null memory IOX_MAYBE_UNUSED) noexcept { // nothing to do in the default implementation } diff --git a/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp b/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp index 83933db823..b7b2673aea 100644 --- a/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp @@ -50,7 +50,7 @@ uint64_t MemPoolCollectionMemoryBlock::alignment() const noexcept return algorithm::max(static_cast(alignof(mepoo::MemoryManager)), memPoolAlignment); } -void MemPoolCollectionMemoryBlock::memoryAvailable(void* memory) noexcept +void MemPoolCollectionMemoryBlock::memoryAvailable(cxx::not_null memory) noexcept { posix::Allocator allocator(memory, size()); auto memoryManager = allocator.allocate(sizeof(mepoo::MemoryManager), alignof(mepoo::MemoryManager)); diff --git a/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp b/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp index 3ca84f0b64..3193379c3b 100644 --- a/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp @@ -45,7 +45,7 @@ uint64_t MemPoolSegmentManagerMemoryBlock::alignment() const noexcept mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT); } -void MemPoolSegmentManagerMemoryBlock::memoryAvailable(void* memory) noexcept +void MemPoolSegmentManagerMemoryBlock::memoryAvailable(cxx::not_null memory) noexcept { posix::Allocator allocator(memory, size()); auto segmentManager = allocator.allocate(sizeof(mepoo::SegmentManager<>), alignof(mepoo::SegmentManager<>)); diff --git a/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp b/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp index 7808a9ba4f..b41aa1916f 100644 --- a/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp @@ -39,7 +39,7 @@ uint64_t PortPoolMemoryBlock::alignment() const noexcept return alignof(PortPoolData); } -void PortPoolMemoryBlock::memoryAvailable(void* memory) noexcept +void PortPoolMemoryBlock::memoryAvailable(cxx::not_null memory) noexcept { m_portPoolData = new (memory) PortPoolData; } diff --git a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp index 4ec7258faf..3d53e34796 100644 --- a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp +++ b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp @@ -36,7 +36,7 @@ class MemoryBlockMock final : public iox::roudi::MemoryBlock return alignmentMock(); } - void memoryAvailable(void* memory) noexcept override + void memoryAvailable(iox::cxx::not_null memory) noexcept override { memoryAvailableMock(memory); } @@ -48,7 +48,7 @@ class MemoryBlockMock final : public iox::roudi::MemoryBlock MOCK_CONST_METHOD0(sizeMock, uint64_t()); MOCK_CONST_METHOD0(alignmentMock, uint64_t()); - MOCK_METHOD1(memoryAvailableMock, void(void*)); + MOCK_METHOD1(memoryAvailableMock, void(iox::cxx::not_null)); MOCK_METHOD0(destroyMock, void()); }; From 447ffa69d84882294461a6e03809079d04968030 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 9 Jun 2021 17:00:39 +0200 Subject: [PATCH 4/8] iox-#842 Restrict access to some MemoryBlock methods Signed-off-by: Mathias Kraus --- .../mempool_collection_memory_block.hpp | 9 ++--- .../mempool_segment_manager_memory_block.hpp | 9 ++--- .../roudi/memory/port_pool_memory_block.hpp | 9 ++--- .../roudi/memory/generic_memory_block.hpp | 9 ++--- .../roudi/memory/memory_block.hpp | 11 +++--- .../test_roudi_generic_memory_block.cpp | 35 +++++++++++++++---- 6 files changed, 55 insertions(+), 27 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp index 37839cd892..c18f401190 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp @@ -53,6 +53,11 @@ class MemPoolCollectionMemoryBlock final : public MemoryBlock /// @note The memory alignment for the MemPools uint64_t alignment() const noexcept override; + /// @brief This function enables the access to the MemoryManager for the MemPools + /// @return an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized + cxx::optional memoryManager() const noexcept; + + protected: /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the MemPools at the location `memory` points to void memoryAvailable(cxx::not_null memory) noexcept override; @@ -61,10 +66,6 @@ class MemPoolCollectionMemoryBlock final : public MemoryBlock /// @note This will clean up the MemPools void destroy() noexcept override; - /// @brief This function enables the access to the MemoryManager for the MemPools - /// @return an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized - cxx::optional memoryManager() const noexcept; - private: mepoo::MePooConfig m_memPoolConfig; mepoo::MemoryManager* m_memoryManager{nullptr}; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp index 2d1b1f85f3..7899b66ac4 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp @@ -48,6 +48,11 @@ class MemPoolSegmentManagerMemoryBlock : public MemoryBlock /// @note The memory alignment for SegmentManager uint64_t alignment() const noexcept override; + /// @brief This function enables the access to the SegmentManager + /// @return an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized + cxx::optional*> segmentManager() const noexcept; + + protected: /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the SegmentManager at the location `memory` points to void memoryAvailable(cxx::not_null memory) noexcept override; @@ -56,10 +61,6 @@ class MemPoolSegmentManagerMemoryBlock : public MemoryBlock /// @note This will clean up the SegmentManager void destroy() noexcept override; - /// @brief This function enables the access to the SegmentManager - /// @return an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized - cxx::optional*> segmentManager() const noexcept; - private: mepoo::SegmentManager<>* m_segmentManager{nullptr}; mepoo::SegmentConfig m_segmentConfig; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp index 0e292a7307..aa2e18b499 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp @@ -48,6 +48,11 @@ class PortPoolMemoryBlock : public MemoryBlock /// @note The memory alignment for the ports uint64_t alignment() const noexcept override; + /// @brief This function enables the access to the PortPool + /// @return an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized + cxx::optional portPool() const noexcept; + + protected: /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the ports at the location `memory` points to void memoryAvailable(cxx::not_null memory) noexcept override; @@ -56,10 +61,6 @@ class PortPoolMemoryBlock : public MemoryBlock /// @note This will clean up the ports void destroy() noexcept override; - /// @brief This function enables the access to the PortPool - /// @return an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized - cxx::optional portPool() const noexcept; - private: PortPoolData* m_portPoolData{nullptr}; }; diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp index fde181c933..a7626f6332 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp @@ -49,10 +49,6 @@ class GenericMemoryBlock final : public MemoryBlock /// @note The alignment of the underlying type T uint64_t alignment() const noexcept override; - /// @copydoc MemoryBlock::destroy - /// @note This will destroy the underlying type T - void destroy() noexcept override; - /// @brief A new element is constructed by forwarding the arguments to the constructor of T. If the MemoryBlock has /// a value then the destructor of T is called. /// @param [in] args are perfectly forwarded to the constructor of T to perform a placement new @@ -64,6 +60,11 @@ class GenericMemoryBlock final : public MemoryBlock /// @return an optional pointer to the underlying type, cxx::nullopt_t if value is not initialized cxx::optional value() const noexcept; + protected: + /// @copydoc MemoryBlock::destroy + /// @note This will destroy the underlying type T + void destroy() noexcept override; + private: T* m_value{nullptr}; }; diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp index 552595506e..2f07485a99 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp @@ -54,6 +54,12 @@ class MemoryBlock /// @return the alignment of the underlying data. virtual uint64_t alignment() const noexcept = 0; + /// @brief This function provides the pointer to the requested memory. + /// @return an optional pointer to a memory block with the requested size and alignment if the memory is available, + /// otherwise a cxx::nullopt_t + cxx::optional memory() const noexcept; + + protected: /// @brief The MemoryProvider calls this either when MemoryProvider::destroy is called or in its destructor. /// @note This function can be called multiple times. Make sure that the implementation can handle this. virtual void destroy() noexcept = 0; @@ -63,11 +69,6 @@ class MemoryBlock /// @param [in] memory pointer to a valid memory block, the same one that the memory() member function would return virtual void memoryAvailable(cxx::not_null memory) noexcept; - /// @brief This function provides the pointer to the requested memory. - /// @return an optional pointer to a memory block with the requested size and alignment if the memory is available, - /// otherwise a cxx::nullopt_t - cxx::optional memory() const noexcept; - private: void* m_memory{nullptr}; }; diff --git a/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp b/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp index c882a130aa..da55947981 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp @@ -145,6 +145,29 @@ class GenericMemoryBlock_NonTrivial_Test : public Test { } + // this is used to access the protected destroy method of GenericMemoryBlock; + // the GenericMemoryBlock is casted to GenericMemoryBlockAccess which can access + // the MemoryBlock::destroy method which uses the vtable to call the + // GenericMemoryBlock::destroy method + class GenericMemoryBlockAccess : public MemoryBlock + { + public: + template + static void callDestroy(GenericMemoryBlock& mb) noexcept + { + // due to the vtable, GenericMemoryBlock::destroy will be called and + // not GenericMemoryBlockAccess::destroy + reinterpret_cast(&mb)->destroy(); + }; + + private: + void destroy() noexcept override + { + static constexpr bool THIS_SHOULD_NEVER_BE_CALLED{false}; + EXPECT_TRUE(THIS_SHOULD_NEVER_BE_CALLED); + } + }; + GenericMemoryBlock sut; MemoryProviderTestImpl memoryProvider; }; @@ -179,7 +202,7 @@ TEST_F(GenericMemoryBlock_NonTrivial_Test, MultipleEmplaceValue) TEST_F(GenericMemoryBlock_NonTrivial_Test, DestroyWithoutCreate) { - sut.destroy(); + GenericMemoryBlockAccess::callDestroy(sut); /// @note we just expect to not terminate } @@ -187,7 +210,7 @@ TEST_F(GenericMemoryBlock_NonTrivial_Test, DestroyWithoutEmplace) { IOX_DISCARD_RESULT(memoryProvider.addMemoryBlock(&sut)); IOX_DISCARD_RESULT(memoryProvider.create()); - sut.destroy(); + GenericMemoryBlockAccess::callDestroy(sut); /// @note we just expect to not terminate } @@ -199,7 +222,7 @@ TEST_F(GenericMemoryBlock_NonTrivial_Test, DestroyWithEmplace) EXPECT_THAT(sut.emplace(EXPECTED_VALUE).value()->m_data, EXPECTED_VALUE); EXPECT_THAT(NonTrivialClass::s_constructorCounter, Eq(1u)); - sut.destroy(); + GenericMemoryBlockAccess::callDestroy(sut); EXPECT_THAT(sut.value().has_value(), Eq(false)); EXPECT_THAT(NonTrivialClass::s_destructorCounter, Eq(1u)); @@ -212,12 +235,12 @@ TEST_F(GenericMemoryBlock_NonTrivial_Test, RepetitiveDestroyWithEmplace) IOX_DISCARD_RESULT(memoryProvider.create()); sut.emplace(EXPECTED_VALUE); - sut.destroy(); + GenericMemoryBlockAccess::callDestroy(sut); EXPECT_THAT(sut.value().has_value(), Eq(false)); - sut.destroy(); - sut.destroy(); + GenericMemoryBlockAccess::callDestroy(sut); + GenericMemoryBlockAccess::callDestroy(sut); EXPECT_THAT(NonTrivialClass::s_destructorCounter, Eq(1u)); } From cd79ad5fa5a15279c8c4d2cfeec672cd4c6b307e Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 9 Jun 2021 18:24:27 +0200 Subject: [PATCH 5/8] iox-#842 Rework testing of protected method Signed-off-by: Mathias Kraus --- .../test_roudi_generic_memory_block.cpp | 37 +++---------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp b/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp index da55947981..443deef469 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_generic_memory_block.cpp @@ -145,29 +145,6 @@ class GenericMemoryBlock_NonTrivial_Test : public Test { } - // this is used to access the protected destroy method of GenericMemoryBlock; - // the GenericMemoryBlock is casted to GenericMemoryBlockAccess which can access - // the MemoryBlock::destroy method which uses the vtable to call the - // GenericMemoryBlock::destroy method - class GenericMemoryBlockAccess : public MemoryBlock - { - public: - template - static void callDestroy(GenericMemoryBlock& mb) noexcept - { - // due to the vtable, GenericMemoryBlock::destroy will be called and - // not GenericMemoryBlockAccess::destroy - reinterpret_cast(&mb)->destroy(); - }; - - private: - void destroy() noexcept override - { - static constexpr bool THIS_SHOULD_NEVER_BE_CALLED{false}; - EXPECT_TRUE(THIS_SHOULD_NEVER_BE_CALLED); - } - }; - GenericMemoryBlock sut; MemoryProviderTestImpl memoryProvider; }; @@ -200,17 +177,15 @@ TEST_F(GenericMemoryBlock_NonTrivial_Test, MultipleEmplaceValue) EXPECT_THAT(emplaceResult.value()->m_data, Eq(EXPECTED_VALUE)); } -TEST_F(GenericMemoryBlock_NonTrivial_Test, DestroyWithoutCreate) +TEST_F(GenericMemoryBlock_NonTrivial_Test, RunDestructorWithoutCreate) { - GenericMemoryBlockAccess::callDestroy(sut); /// @note we just expect to not terminate } -TEST_F(GenericMemoryBlock_NonTrivial_Test, DestroyWithoutEmplace) +TEST_F(GenericMemoryBlock_NonTrivial_Test, RunDestructorWithoutEmplace) { IOX_DISCARD_RESULT(memoryProvider.addMemoryBlock(&sut)); IOX_DISCARD_RESULT(memoryProvider.create()); - GenericMemoryBlockAccess::callDestroy(sut); /// @note we just expect to not terminate } @@ -222,7 +197,7 @@ TEST_F(GenericMemoryBlock_NonTrivial_Test, DestroyWithEmplace) EXPECT_THAT(sut.emplace(EXPECTED_VALUE).value()->m_data, EXPECTED_VALUE); EXPECT_THAT(NonTrivialClass::s_constructorCounter, Eq(1u)); - GenericMemoryBlockAccess::callDestroy(sut); + IOX_DISCARD_RESULT(memoryProvider.destroy()); EXPECT_THAT(sut.value().has_value(), Eq(false)); EXPECT_THAT(NonTrivialClass::s_destructorCounter, Eq(1u)); @@ -235,12 +210,12 @@ TEST_F(GenericMemoryBlock_NonTrivial_Test, RepetitiveDestroyWithEmplace) IOX_DISCARD_RESULT(memoryProvider.create()); sut.emplace(EXPECTED_VALUE); - GenericMemoryBlockAccess::callDestroy(sut); + IOX_DISCARD_RESULT(memoryProvider.destroy()); EXPECT_THAT(sut.value().has_value(), Eq(false)); - GenericMemoryBlockAccess::callDestroy(sut); - GenericMemoryBlockAccess::callDestroy(sut); + IOX_DISCARD_RESULT(memoryProvider.destroy()); + IOX_DISCARD_RESULT(memoryProvider.destroy()); EXPECT_THAT(NonTrivialClass::s_destructorCounter, Eq(1u)); } From ff93cf135fb1403593e4a23e0acb05cff2da4b5f Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Fri, 11 Jun 2021 13:27:28 +0200 Subject: [PATCH 6/8] iox-#842 Update copyright and add noexcept Signed-off-by: Mathias Kraus --- .../internal/roudi/memory/mempool_collection_memory_block.hpp | 1 + .../roudi/memory/mempool_segment_manager_memory_block.hpp | 1 + .../internal/roudi/memory/port_pool_memory_block.hpp | 1 + .../include/iceoryx_posh/roudi/memory/generic_memory_block.hpp | 1 + .../include/iceoryx_posh/roudi/memory/memory_block.hpp | 3 ++- .../iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp | 1 + iceoryx_posh/source/roudi/memory/memory_block.cpp | 1 + iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp | 1 + iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp | 1 + 9 files changed, 10 insertions(+), 1 deletion(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp index c18f401190..354a49c36b 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp index 7899b66ac4..3ec09aa146 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp index aa2e18b499..a24bbb2733 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp index a7626f6332..d023a2859a 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/generic_memory_block.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp index 2f07485a99..2ea5a89de0 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ class MemoryBlock public: MemoryBlock() noexcept = default; - virtual ~MemoryBlock() = default; + virtual ~MemoryBlock() noexcept = default; /// @note this is intentional not movable/copyable, since a pointer to the memory block is registered at a /// MemoryProvider and therefore an instance of a MemoryBlock must be pinned to memory diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp index 40469e1d0b..cf8a5b6543 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/posix_shm_memory_provider.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/source/roudi/memory/memory_block.cpp b/iceoryx_posh/source/roudi/memory/memory_block.cpp index 52c4712793..071ee201d7 100644 --- a/iceoryx_posh/source/roudi/memory/memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/memory_block.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp b/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp index b41aa1916f..7cc0baccf5 100644 --- a/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp index 3d53e34796..ebc40d0132 100644 --- a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp +++ b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved. +// Copyright (c) 2021 by Apex.AI Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From 73759008f59fabe601ee97efae867f48b399d77f Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Fri, 11 Jun 2021 14:33:34 +0200 Subject: [PATCH 7/8] iox-#842 Rename memoryAvailable to onMemoryAvailable Signed-off-by: Mathias Kraus --- .../roudi/memory/mempool_collection_memory_block.hpp | 2 +- .../roudi/memory/mempool_segment_manager_memory_block.hpp | 2 +- .../internal/roudi/memory/port_pool_memory_block.hpp | 2 +- .../include/iceoryx_posh/roudi/memory/memory_block.hpp | 2 +- iceoryx_posh/source/roudi/memory/memory_block.cpp | 2 +- iceoryx_posh/source/roudi/memory/memory_provider.cpp | 2 +- .../roudi/memory/mempool_collection_memory_block.cpp | 2 +- .../roudi/memory/mempool_segment_manager_memory_block.cpp | 2 +- .../source/roudi/memory/port_pool_memory_block.cpp | 2 +- iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp | 6 +++--- .../test/moduletests/test_roudi_memory_manager.cpp | 6 +++--- .../test/moduletests/test_roudi_memory_provider.cpp | 8 ++++---- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp index 354a49c36b..ccca0bd997 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp @@ -61,7 +61,7 @@ class MemPoolCollectionMemoryBlock final : public MemoryBlock protected: /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the MemPools at the location `memory` points to - void memoryAvailable(cxx::not_null memory) noexcept override; + void onMemoryAvailable(cxx::not_null memory) noexcept override; /// @copydoc MemoryBlock::destroy /// @note This will clean up the MemPools diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp index 3ec09aa146..f889a14f32 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp @@ -56,7 +56,7 @@ class MemPoolSegmentManagerMemoryBlock : public MemoryBlock protected: /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the SegmentManager at the location `memory` points to - void memoryAvailable(cxx::not_null memory) noexcept override; + void onMemoryAvailable(cxx::not_null memory) noexcept override; /// @copydoc MemoryBlock::destroy /// @note This will clean up the SegmentManager diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp index a24bbb2733..94002bc663 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp @@ -56,7 +56,7 @@ class PortPoolMemoryBlock : public MemoryBlock protected: /// @copydoc MemoryBlock::memoryAvailable /// @note This will create the ports at the location `memory` points to - void memoryAvailable(cxx::not_null memory) noexcept override; + void onMemoryAvailable(cxx::not_null memory) noexcept override; /// @copydoc MemoryBlock::destroy /// @note This will clean up the ports diff --git a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp index 2ea5a89de0..ed71a80e7a 100644 --- a/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/roudi/memory/memory_block.hpp @@ -68,7 +68,7 @@ class MemoryBlock /// @brief This function is called once the memory is available and is therefore the earliest possibility to use the /// memory. /// @param [in] memory pointer to a valid memory block, the same one that the memory() member function would return - virtual void memoryAvailable(cxx::not_null memory) noexcept; + virtual void onMemoryAvailable(cxx::not_null memory) noexcept; private: void* m_memory{nullptr}; diff --git a/iceoryx_posh/source/roudi/memory/memory_block.cpp b/iceoryx_posh/source/roudi/memory/memory_block.cpp index 071ee201d7..8c33434256 100644 --- a/iceoryx_posh/source/roudi/memory/memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/memory_block.cpp @@ -22,7 +22,7 @@ namespace iox { namespace roudi { -void MemoryBlock::memoryAvailable(cxx::not_null memory IOX_MAYBE_UNUSED) noexcept +void MemoryBlock::onMemoryAvailable(cxx::not_null memory IOX_MAYBE_UNUSED) noexcept { // nothing to do in the default implementation } diff --git a/iceoryx_posh/source/roudi/memory/memory_provider.cpp b/iceoryx_posh/source/roudi/memory/memory_provider.cpp index 1c92a273f6..62613dfd4e 100644 --- a/iceoryx_posh/source/roudi/memory/memory_provider.cpp +++ b/iceoryx_posh/source/roudi/memory/memory_provider.cpp @@ -146,7 +146,7 @@ void MemoryProvider::announceMemoryAvailable() noexcept { for (auto memoryBlock : m_memoryBlocks) { - memoryBlock->memoryAvailable(memoryBlock->m_memory); + memoryBlock->onMemoryAvailable(memoryBlock->m_memory); } m_memoryAvailableAnnounced = true; diff --git a/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp b/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp index b7b2673aea..5e5b3231e3 100644 --- a/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/mempool_collection_memory_block.cpp @@ -50,7 +50,7 @@ uint64_t MemPoolCollectionMemoryBlock::alignment() const noexcept return algorithm::max(static_cast(alignof(mepoo::MemoryManager)), memPoolAlignment); } -void MemPoolCollectionMemoryBlock::memoryAvailable(cxx::not_null memory) noexcept +void MemPoolCollectionMemoryBlock::onMemoryAvailable(cxx::not_null memory) noexcept { posix::Allocator allocator(memory, size()); auto memoryManager = allocator.allocate(sizeof(mepoo::MemoryManager), alignof(mepoo::MemoryManager)); diff --git a/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp b/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp index 3193379c3b..26c9efd77c 100644 --- a/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/mempool_segment_manager_memory_block.cpp @@ -45,7 +45,7 @@ uint64_t MemPoolSegmentManagerMemoryBlock::alignment() const noexcept mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT); } -void MemPoolSegmentManagerMemoryBlock::memoryAvailable(cxx::not_null memory) noexcept +void MemPoolSegmentManagerMemoryBlock::onMemoryAvailable(cxx::not_null memory) noexcept { posix::Allocator allocator(memory, size()); auto segmentManager = allocator.allocate(sizeof(mepoo::SegmentManager<>), alignof(mepoo::SegmentManager<>)); diff --git a/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp b/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp index 7cc0baccf5..c4b54ab0af 100644 --- a/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp +++ b/iceoryx_posh/source/roudi/memory/port_pool_memory_block.cpp @@ -40,7 +40,7 @@ uint64_t PortPoolMemoryBlock::alignment() const noexcept return alignof(PortPoolData); } -void PortPoolMemoryBlock::memoryAvailable(cxx::not_null memory) noexcept +void PortPoolMemoryBlock::onMemoryAvailable(cxx::not_null memory) noexcept { m_portPoolData = new (memory) PortPoolData; } diff --git a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp index ebc40d0132..a8c5865967 100644 --- a/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp +++ b/iceoryx_posh/test/mocks/roudi_memory_block_mock.hpp @@ -37,9 +37,9 @@ class MemoryBlockMock final : public iox::roudi::MemoryBlock return alignmentMock(); } - void memoryAvailable(iox::cxx::not_null memory) noexcept override + void onMemoryAvailable(iox::cxx::not_null memory) noexcept override { - memoryAvailableMock(memory); + onMemoryAvailableMock(memory); } void destroy() noexcept override @@ -49,7 +49,7 @@ class MemoryBlockMock final : public iox::roudi::MemoryBlock MOCK_CONST_METHOD0(sizeMock, uint64_t()); MOCK_CONST_METHOD0(alignmentMock, uint64_t()); - MOCK_METHOD1(memoryAvailableMock, void(iox::cxx::not_null)); + MOCK_METHOD1(onMemoryAvailableMock, void(iox::cxx::not_null)); MOCK_METHOD0(destroyMock, void()); }; diff --git a/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp b/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp index acf786adb7..13e31e759c 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_memory_manager.cpp @@ -80,10 +80,10 @@ TEST_F(RouDiMemoryManager_Test, CallingCreateMemoryWithMemoryProviderSucceeds) uint64_t MEMORY_ALIGNMENT_2{16}; EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_1)); EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); - EXPECT_CALL(memoryBlock1, memoryAvailableMock(_)); + EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)); EXPECT_CALL(memoryBlock2, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_2)); EXPECT_CALL(memoryBlock2, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_2)); - EXPECT_CALL(memoryBlock2, memoryAvailableMock(_)); + EXPECT_CALL(memoryBlock2, onMemoryAvailableMock(_)); IOX_DISCARD_RESULT(memoryProvider1.addMemoryBlock(&memoryBlock1)); IOX_DISCARD_RESULT(memoryProvider2.addMemoryBlock(&memoryBlock2)); @@ -114,7 +114,7 @@ TEST_F(RouDiMemoryManager_Test, RouDiMemoryManagerDTorTriggersMemoryProviderDest uint64_t MEMORY_ALIGNMENT_1{8}; EXPECT_CALL(memoryBlock1, sizeMock()).WillRepeatedly(Return(MEMORY_SIZE_1)); EXPECT_CALL(memoryBlock1, alignmentMock()).WillRepeatedly(Return(MEMORY_ALIGNMENT_1)); - EXPECT_CALL(memoryBlock1, memoryAvailableMock(_)); + EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)); IOX_DISCARD_RESULT(memoryProvider1.addMemoryBlock(&memoryBlock1)); diff --git a/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp b/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp index 069977dd7e..23021d12d6 100644 --- a/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp +++ b/iceoryx_posh/test/moduletests/test_roudi_memory_provider.cpp @@ -193,7 +193,7 @@ TEST_F(MemoryProvider_Test, CreateAndAnnounceWithOneMemoryBlock) { ASSERT_FALSE(commonSetup().has_error()); - EXPECT_CALL(memoryBlock1, memoryAvailableMock(_)).Times(1); + EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)).Times(1); sut.announceMemoryAvailable(); EXPECT_THAT(sut.isAvailableAnnounced(), Eq(true)); @@ -215,8 +215,8 @@ TEST_F(MemoryProvider_Test, CreateAndAnnounceWithMultipleMemoryBlocks) .Times(1); EXPECT_THAT(sut.create().has_error(), Eq(false)); - EXPECT_CALL(memoryBlock1, memoryAvailableMock(_)).Times(1); - EXPECT_CALL(memoryBlock2, memoryAvailableMock(_)).Times(1); + EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)).Times(1); + EXPECT_CALL(memoryBlock2, onMemoryAvailableMock(_)).Times(1); sut.announceMemoryAvailable(); EXPECT_THAT(sut.isAvailableAnnounced(), Eq(true)); @@ -248,7 +248,7 @@ TEST_F(MemoryProvider_Test, MultipleAnnouncesAreSuppressed) { ASSERT_FALSE(commonSetup().has_error()); - EXPECT_CALL(memoryBlock1, memoryAvailableMock(_)).Times(1); + EXPECT_CALL(memoryBlock1, onMemoryAvailableMock(_)).Times(1); sut.announceMemoryAvailable(); sut.announceMemoryAvailable(); // this shouldn't trigger a second memoryAvailable call on memoryBlock1 From cf147f557a8cb4bba377cac4798e113cf04eac1c Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Mon, 14 Jun 2021 11:20:04 +0200 Subject: [PATCH 8/8] iox-#842 Fix documentation after rename Signed-off-by: Mathias Kraus --- .../internal/roudi/memory/mempool_collection_memory_block.hpp | 2 +- .../roudi/memory/mempool_segment_manager_memory_block.hpp | 2 +- .../internal/roudi/memory/port_pool_memory_block.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp index ccca0bd997..9e9b1dcf1d 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_collection_memory_block.hpp @@ -59,7 +59,7 @@ class MemPoolCollectionMemoryBlock final : public MemoryBlock cxx::optional memoryManager() const noexcept; protected: - /// @copydoc MemoryBlock::memoryAvailable + /// @copydoc MemoryBlock::onMemoryAvailable /// @note This will create the MemPools at the location `memory` points to void onMemoryAvailable(cxx::not_null memory) noexcept override; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp index f889a14f32..7f050e179d 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/mempool_segment_manager_memory_block.hpp @@ -54,7 +54,7 @@ class MemPoolSegmentManagerMemoryBlock : public MemoryBlock cxx::optional*> segmentManager() const noexcept; protected: - /// @copydoc MemoryBlock::memoryAvailable + /// @copydoc MemoryBlock::onMemoryAvailable /// @note This will create the SegmentManager at the location `memory` points to void onMemoryAvailable(cxx::not_null memory) noexcept override; diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp index 94002bc663..015218e463 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/memory/port_pool_memory_block.hpp @@ -54,7 +54,7 @@ class PortPoolMemoryBlock : public MemoryBlock cxx::optional portPool() const noexcept; protected: - /// @copydoc MemoryBlock::memoryAvailable + /// @copydoc MemoryBlock::onMemoryAvailable /// @note This will create the ports at the location `memory` points to void onMemoryAvailable(cxx::not_null memory) noexcept override;