2018-02-13 10:36:19 -05:00
|
|
|
#ifndef OSRM_ENGINE_DATAFACADE_MMAP_MEMORY_ALLOCATOR_HPP_
|
|
|
|
#define OSRM_ENGINE_DATAFACADE_MMAP_MEMORY_ALLOCATOR_HPP_
|
|
|
|
|
|
|
|
#include "engine/datafacade/contiguous_block_allocator.hpp"
|
|
|
|
|
|
|
|
#include "storage/storage_config.hpp"
|
|
|
|
|
|
|
|
#include "util/vector_view.hpp"
|
|
|
|
|
|
|
|
#include <boost/iostreams/device/mapped_file.hpp>
|
|
|
|
|
|
|
|
#include <memory>
|
2018-10-27 02:48:51 -04:00
|
|
|
#include <string>
|
2018-02-13 10:36:19 -05:00
|
|
|
|
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace engine
|
|
|
|
{
|
|
|
|
namespace datafacade
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This allocator uses file backed mmap memory block as the data location.
|
|
|
|
*/
|
|
|
|
class MMapMemoryAllocator : public ContiguousBlockAllocator
|
|
|
|
{
|
|
|
|
public:
|
2018-10-27 02:48:51 -04:00
|
|
|
explicit MMapMemoryAllocator(const storage::StorageConfig &config);
|
2018-02-13 10:36:19 -05:00
|
|
|
~MMapMemoryAllocator() override final;
|
|
|
|
|
|
|
|
// interface to give access to the datafacades
|
2018-04-04 19:05:34 -04:00
|
|
|
const storage::SharedDataIndex &GetIndex() override final;
|
2018-02-13 10:36:19 -05:00
|
|
|
|
|
|
|
private:
|
2018-04-04 19:05:34 -04:00
|
|
|
storage::SharedDataIndex index;
|
2018-10-27 02:48:51 -04:00
|
|
|
std::vector<boost::iostreams::mapped_file> mapped_memory_files;
|
|
|
|
std::string rtree_filename;
|
2018-02-13 10:36:19 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace datafacade
|
|
|
|
} // namespace engine
|
|
|
|
} // namespace osrm
|
|
|
|
|
|
|
|
#endif // OSRM_ENGINE_DATAFACADE_SHARED_MEMORY_ALLOCATOR_HPP_
|