unite process/shared_memory datafacades into a single type using an allocator scheme

This commit is contained in:
Moritz Kobitzsch
2017-01-18 13:44:17 +01:00
committed by Patrick Niklaus
parent 75e0b5a5c4
commit b8beac2d00
11 changed files with 205 additions and 110 deletions
@@ -0,0 +1,33 @@
#include "engine/datafacade/process_memory_allocator.hpp"
#include "storage/storage.hpp"
#include "boost/assert.hpp"
namespace osrm
{
namespace engine
{
namespace datafacade
{
ProcessMemoryAllocator::ProcessMemoryAllocator(const storage::StorageConfig &config)
{
storage::Storage storage(config);
// Calculate the layout/size of the memory block
internal_layout = std::make_unique<storage::DataLayout>();
storage.PopulateLayout(*internal_layout);
// Allocate the memory block, then load data from files into it
internal_memory = std::make_unique<char[]>(internal_layout->GetSizeOfLayout());
storage.PopulateData(*internal_layout, internal_memory.get());
}
ProcessMemoryAllocator::~ProcessMemoryAllocator() {}
storage::DataLayout &ProcessMemoryAllocator::GetLayout() { return *internal_layout.get(); }
char *ProcessMemoryAllocator::GetMemory() { return internal_memory.get(); }
} // namespace datafacade
} // namespace engine
} // namespace osrm