Rename the datafacades to more clearly describe what they do.

This commit is contained in:
Daniel Patterson 2016-11-14 18:34:39 -08:00
parent 4760b85930
commit 608044305d
5 changed files with 31 additions and 30 deletions

View File

@ -102,10 +102,10 @@ class DataWatchdog
boost::upgrade_to_unique_lock<boost::upgrade_mutex> unique_facade_lock(facade_lock);
current_timestamp = *shared_timestamp;
facade = std::make_shared<datafacade::SharedDataFacade>(shared_barriers,
current_timestamp.layout,
current_timestamp.data,
current_timestamp.timestamp);
facade = std::make_shared<datafacade::SharedMemoryDataFacade>(shared_barriers,
current_timestamp.layout,
current_timestamp.data,
current_timestamp.timestamp);
return get_locked_facade();
}
@ -119,7 +119,7 @@ class DataWatchdog
std::unique_ptr<storage::SharedMemory> shared_regions;
mutable boost::shared_mutex facade_mutex;
std::shared_ptr<datafacade::SharedDataFacade> facade;
std::shared_ptr<datafacade::SharedMemoryDataFacade> facade;
storage::SharedDataTimestamp current_timestamp;
};
}

View File

@ -1,7 +1,5 @@
#ifndef MEMORYBLOCK_DATAFACADE_HPP
#define MEMORYBLOCK_DATAFACADE_HPP
// implements all data storage when shared memory _IS_ used
#ifndef CONTIGUOUS_INTERNALMEM_DATAFACADE_HPP
#define CONTIGUOUS_INTERNALMEM_DATAFACADE_HPP
#include "engine/datafacade/datafacade_base.hpp"
@ -57,9 +55,12 @@ using OSMNodeArrayRef = ConstArrayRef<const OSMNodeID *>;
/**
* This base class implements the Datafacade interface for accessing
* data that's stored in a single large block of memory.
* data that's stored in a single large block of memory (RAM).
*
* In this case "internal memory" refers to RAM - as opposed to "external memory",
* which usually refers to disk.
*/
class BigRAMBlockDataFacadeBase : public BaseDataFacade
class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
{
private:
using super = BaseDataFacade;
@ -940,4 +941,4 @@ class BigRAMBlockDataFacadeBase : public BaseDataFacade
}
}
#endif // MEMORYBLOCK_DATAFACADE_HPP
#endif // CONTIGUOUS_INTERNALMEM_DATAFACADE_HPP

View File

@ -1,9 +1,9 @@
#ifndef INTERNAL_DATAFACADE_HPP
#define INTERNAL_DATAFACADE_HPP
#ifndef PROCESS_MEMORY_DATAFACADE_HPP
#define PROCESS_MEMORY_DATAFACADE_HPP
// implements all data storage when shared memory is _NOT_ used
#include "engine/datafacade/bigramblock_datafacade_base.hpp"
#include "engine/datafacade/contiguous_internalmem_datafacade_base.hpp"
#include "storage/storage.hpp"
namespace osrm
@ -16,12 +16,12 @@ namespace datafacade
/**
* This datafacade uses a process-local memory block to load
* data into. The structure and layout is the same as when using
* shared memory, so this class, and the SharedDatafacade both
* shared memory, so this class, and the SharedMemoryDataFacade both
* share a common base.
* This class holds a unique_ptr to the memory block, so it
* is auto-freed upon destruction.
*/
class InternalDataFacade final : public BigRAMBlockDataFacadeBase
class ProcessMemoryDataFacade final : public ContiguousInternalMemoryDataFacadeBase
{
private:
@ -29,7 +29,7 @@ class InternalDataFacade final : public BigRAMBlockDataFacadeBase
std::unique_ptr<storage::DataLayout> internal_layout;
public:
explicit InternalDataFacade(const storage::StorageConfig &config)
explicit ProcessMemoryDataFacade(const storage::StorageConfig &config)
{
storage::Storage storage(config);
@ -49,4 +49,4 @@ class InternalDataFacade final : public BigRAMBlockDataFacadeBase
}
}
#endif // INTERNAL_DATAFACADE_HPP
#endif // PROCESS_MEMORY_DATAFACADE_HPP

View File

@ -6,7 +6,7 @@
#include "storage/shared_barriers.hpp"
#include "storage/shared_datatype.hpp"
#include "storage/shared_memory.hpp"
#include "engine/datafacade/bigramblock_datafacade_base.hpp"
#include "engine/datafacade/contiguous_internalmem_datafacade_base.hpp"
namespace osrm
{
@ -17,10 +17,10 @@ namespace datafacade
/**
* This datafacade uses an IPC shared memory block as the data location.
* Many SharedDataFacade objects can be created that point to the same shared
* Many SharedMemoryDataFacade objects can be created that point to the same shared
* memory block.
*/
class SharedDataFacade : public BigRAMBlockDataFacadeBase
class SharedMemoryDataFacade : public ContiguousInternalMemoryDataFacadeBase
{
protected:
@ -31,12 +31,12 @@ class SharedDataFacade : public BigRAMBlockDataFacadeBase
storage::SharedDataType data_region;
unsigned shared_timestamp;
SharedDataFacade() {}
SharedMemoryDataFacade() {}
public:
// this function handle the deallocation of the shared memory it we can prove it will not be
// used anymore. We crash hard here if something goes wrong (noexcept).
virtual ~SharedDataFacade() noexcept
virtual ~SharedMemoryDataFacade() noexcept
{
boost::interprocess::scoped_lock<boost::interprocess::named_sharable_mutex> exclusive_lock(
data_region == storage::DATA_1 ? shared_barriers->regions_1_mutex
@ -67,10 +67,10 @@ class SharedDataFacade : public BigRAMBlockDataFacadeBase
}
}
SharedDataFacade(const std::shared_ptr<storage::SharedBarriers> &shared_barriers_,
storage::SharedDataType layout_region_,
storage::SharedDataType data_region_,
unsigned shared_timestamp_)
SharedMemoryDataFacade(const std::shared_ptr<storage::SharedBarriers> &shared_barriers_,
storage::SharedDataType layout_region_,
storage::SharedDataType data_region_,
unsigned shared_timestamp_)
: shared_barriers(shared_barriers_), layout_region(layout_region_),
data_region(data_region_), shared_timestamp(shared_timestamp_)
{

View File

@ -3,7 +3,7 @@
#include "engine/engine_config.hpp"
#include "engine/status.hpp"
#include "engine/datafacade/internal_memory_datafacade.hpp"
#include "engine/datafacade/process_memory_datafacade.hpp"
#include "engine/datafacade/shared_memory_datafacade.hpp"
#include "storage/shared_barriers.hpp"
@ -81,7 +81,7 @@ Engine::Engine(const EngineConfig &config)
throw util::exception("Invalid file paths given!");
}
immutable_data_facade =
std::make_shared<datafacade::InternalDataFacade>(config.storage_config);
std::make_shared<datafacade::ProcessMemoryDataFacade>(config.storage_config);
}
}