From 23657bc8a770734a74f73f6d07075130a366ef00 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Tue, 10 Mar 2020 15:50:18 +0100 Subject: [HICN-544] Do not block reading incoming messages in memif connector. Signed-off-by: Mauro Sardara Change-Id: I844dfa64a977c9c41bfc103bb110c274802b1839 Signed-off-by: Mauro Sardara --- libtransport/src/core/portal.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libtransport/src/core/portal.h') diff --git a/libtransport/src/core/portal.h b/libtransport/src/core/portal.h index 34dfbd826..05715543a 100644 --- a/libtransport/src/core/portal.h +++ b/libtransport/src/core/portal.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -52,21 +53,20 @@ class HandlerMemory { static constexpr std::size_t memory_size = 1024 * 1024; public: - HandlerMemory() : index_(0) {} + HandlerMemory() {} HandlerMemory(const HandlerMemory &) = delete; HandlerMemory &operator=(const HandlerMemory &) = delete; TRANSPORT_ALWAYS_INLINE void *allocate(std::size_t size) { - return &storage_[index_++ % memory_size]; + return utils::FixedBlockAllocator<128, 4096>::getInstance() + ->allocateBlock(); } - TRANSPORT_ALWAYS_INLINE void deallocate(void *pointer) {} - - private: - // Storage space used for handler-based custom memory allocation. - typename std::aligned_storage<128>::type storage_[memory_size]; - uint32_t index_; + TRANSPORT_ALWAYS_INLINE void deallocate(void *pointer) { + utils::FixedBlockAllocator<128, 4096>::getInstance()->deallocateBlock( + pointer); + } #else public: HandlerMemory() {} -- cgit 1.2.3-korg