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"
|
|
|
|
|
2018-04-04 19:05:34 -04:00
|
|
|
#include "storage/shared_data_index.hpp"
|
2017-01-18 07:44:17 -05:00
|
|
|
#include "storage/shared_memory.hpp"
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::engine::datafacade
|
2017-01-18 07:44:17 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
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.
|
|
|
|
*/
|
2022-06-27 19:14:28 -04:00
|
|
|
class SharedMemoryAllocator final : public ContiguousBlockAllocator
|
2017-01-18 07:44:17 -05:00
|
|
|
{
|
|
|
|
public:
|
2018-04-05 20:50:12 -04:00
|
|
|
explicit SharedMemoryAllocator(
|
|
|
|
const std::vector<storage::SharedRegionRegister::ShmKey> &shm_keys);
|
2017-01-18 07:44:17 -05:00
|
|
|
~SharedMemoryAllocator() override final;
|
|
|
|
|
|
|
|
// interface to give access to the datafacades
|
2018-04-04 19:05:34 -04:00
|
|
|
const storage::SharedDataIndex &GetIndex() override final;
|
2017-01-18 07:44:17 -05:00
|
|
|
|
|
|
|
private:
|
2018-04-04 19:05:34 -04:00
|
|
|
storage::SharedDataIndex index;
|
|
|
|
std::vector<std::unique_ptr<storage::SharedMemory>> memory_regions;
|
2017-01-18 07:44:17 -05:00
|
|
|
};
|
|
|
|
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::engine::datafacade
|
2017-01-18 07:44:17 -05:00
|
|
|
|
|
|
|
#endif // OSRM_ENGINE_DATAFACADE_SHARED_MEMORY_ALLOCATOR_HPP_
|