2017-01-18 07:44:17 -05:00
|
|
|
#ifndef OSRM_ENGINE_DATAFACADE_SHARED_MEMORY_ALLOCATOR_HPP_
|
|
|
|
#define OSRM_ENGINE_DATAFACADE_SHARED_MEMORY_ALLOCATOR_HPP_
|
|
|
|
|
|
|
|
#include "engine/datafacade/contiguous_block_allocator.hpp"
|
|
|
|
|
|
|
|
#include "storage/shared_datatype.hpp"
|
|
|
|
#include "storage/shared_memory.hpp"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace datafacade
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2018-02-05 06:40:18 -05:00
|
|
|
* This allocator uses an IPC shared memory block as the data location.
|
|
|
|
* Many SharedMemoryDataFacade objects can be created that point to the same shared
|
|
|
|
* memory block.
|
|
|
|
*/
|
2017-01-18 07:44:17 -05:00
|
|
|
class SharedMemoryAllocator : public ContiguousBlockAllocator
|
|
|
|
{
|
|
|
|
public:
|
2018-03-28 08:11:47 -04:00
|
|
|
explicit SharedMemoryAllocator(storage::SharedRegionRegister::ShmKey data_shm_key);
|
2017-01-18 07:44:17 -05:00
|
|
|
~SharedMemoryAllocator() override final;
|
|
|
|
|
|
|
|
// interface to give access to the datafacades
|
2018-03-22 15:16:19 -04:00
|
|
|
const storage::DataLayout &GetLayout() override final;
|
2017-01-18 07:44:17 -05:00
|
|
|
char *GetMemory() override final;
|
|
|
|
|
|
|
|
private:
|
2018-03-22 15:16:19 -04:00
|
|
|
std::size_t layout_size;
|
|
|
|
storage::DataLayout data_layout;
|
2017-01-18 07:44:17 -05:00
|
|
|
std::unique_ptr<storage::SharedMemory> m_large_memory;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace datafacade
|
|
|
|
} // namespace engine
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
#endif // OSRM_ENGINE_DATAFACADE_SHARED_MEMORY_ALLOCATOR_HPP_
|