diff options
author | Mauro Sardara <msardara@cisco.com> | 2020-03-10 15:50:18 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2020-03-10 15:57:31 +0100 |
commit | 23657bc8a770734a74f73f6d07075130a366ef00 (patch) | |
tree | e5c00a85ceca00db9d8926824f7f59de67536972 /libtransport/src/core/portal.h | |
parent | 01d76a603fba7db5cfb83a1fbc3b369f2e4a4823 (diff) |
[HICN-544] Do not block reading incoming messages in memif connector.
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Change-Id: I844dfa64a977c9c41bfc103bb110c274802b1839
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/core/portal.h')
-rw-r--r-- | libtransport/src/core/portal.h | 16 |
1 files changed, 8 insertions, 8 deletions
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 <hicn/transport/interfaces/portal.h> #include <hicn/transport/portability/portability.h> #include <hicn/transport/utils/log.h> +#include <hicn/transport/utils/fixed_block_allocator.h> #include <core/forwarder_interface.h> #include <core/pending_interest.h> @@ -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() {} |