1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

Revert "villas/memory: make MemoryBlock use shared_ptr instead of unique_ptr"

Instead, we want to rework the Memory handling entirely.

This reverts commit c8128db732b0b01a418f26a0a54a2464fe1d09e6.

Signed-off-by: Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
This commit is contained in:
Niklas Eiling 2023-01-04 10:32:36 +01:00 committed by Steffen Vogel
parent 1157ce2996
commit 3b2d3fb3fb

View file

@ -76,12 +76,6 @@ public:
memoryBlock(std::move(mem))
{ }
// Take ownership of the MemoryBlock
MemoryAccessor(std::shared_ptr<MemoryBlock> mem) :
translation(MemoryManager::get().getTranslationFromProcess(mem->getAddrSpaceId())),
memoryBlock(std::move(mem))
{ }
// Just act as an accessor, do not take ownership of MemoryBlock
MemoryAccessor(const MemoryBlock &mem) :
translation(MemoryManager::get().getTranslationFromProcess(mem.getAddrSpaceId()))
@ -112,10 +106,10 @@ public:
return reinterpret_cast<T*>(translation.getLocalAddr(0));
}
const std::shared_ptr<MemoryBlock>
const MemoryBlock&
getMemoryBlock() const
{
if (not memoryBlock) throw std::bad_alloc(); else return memoryBlock;
if (not memoryBlock) throw std::bad_alloc(); else return *memoryBlock;
}
private:
@ -123,7 +117,7 @@ private:
MemoryTranslation translation;
// Take the unique pointer in case user wants this class to have ownership
std::shared_ptr<MemoryBlock> memoryBlock;
std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn> memoryBlock;
};
/**