fix implicit conversion in TemporaryStorage

This commit is contained in:
Dennis Luxen 2014-07-24 11:23:03 +02:00
parent faee894052
commit 37d6257524
3 changed files with 13 additions and 10 deletions

View File

@ -989,7 +989,7 @@ class Contractor
std::shared_ptr<ContractorGraph> contractor_graph; std::shared_ptr<ContractorGraph> contractor_graph;
std::vector<ContractorGraph::InputEdge> contracted_edge_list; std::vector<ContractorGraph::InputEdge> contracted_edge_list;
unsigned edge_storage_slot; std::size_t edge_storage_slot;
uint64_t temp_edge_counter; uint64_t temp_edge_counter;
std::vector<NodeID> orig_node_id_to_new_id_map; std::vector<NodeID> orig_node_id_to_new_id_map;
XORFastHash fast_hash; XORFastHash fast_hash;

View File

@ -27,6 +27,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "TemporaryStorage.h" #include "TemporaryStorage.h"
#include <boost/range/irange.hpp>
StreamData::StreamData() StreamData::StreamData()
: write_mode(true), : write_mode(true),
temp_path(boost::filesystem::unique_path(temp_directory / TemporaryFilePattern)), temp_path(boost::filesystem::unique_path(temp_directory / TemporaryFilePattern)),
@ -53,14 +56,14 @@ TemporaryStorage::~TemporaryStorage() { RemoveAll(); }
void TemporaryStorage::RemoveAll() void TemporaryStorage::RemoveAll()
{ {
boost::mutex::scoped_lock lock(mutex); boost::mutex::scoped_lock lock(mutex);
for (unsigned slot_id = 0; slot_id < stream_data_list.size(); ++slot_id) for (const auto slot_id : boost::irange((std::size_t)0, stream_data_list.size()))
{ {
DeallocateSlot(slot_id); DeallocateSlot(slot_id);
} }
stream_data_list.clear(); stream_data_list.clear();
} }
int TemporaryStorage::AllocateSlot() std::size_t TemporaryStorage::AllocateSlot()
{ {
boost::mutex::scoped_lock lock(mutex); boost::mutex::scoped_lock lock(mutex);
try { stream_data_list.push_back(StreamData()); } try { stream_data_list.push_back(StreamData()); }
@ -69,7 +72,7 @@ int TemporaryStorage::AllocateSlot()
return stream_data_list.size() - 1; return stream_data_list.size() - 1;
} }
void TemporaryStorage::DeallocateSlot(const int slot_id) void TemporaryStorage::DeallocateSlot(const std::size_t slot_id)
{ {
try try
{ {
@ -89,7 +92,7 @@ void TemporaryStorage::DeallocateSlot(const int slot_id)
catch (boost::filesystem::filesystem_error &e) { Abort(e); } catch (boost::filesystem::filesystem_error &e) { Abort(e); }
} }
void TemporaryStorage::WriteToSlot(const int slot_id, char *pointer, const std::size_t size) void TemporaryStorage::WriteToSlot(const std::size_t slot_id, char *pointer, const std::size_t size)
{ {
try try
{ {
@ -109,7 +112,7 @@ void TemporaryStorage::WriteToSlot(const int slot_id, char *pointer, const std::
} }
catch (boost::filesystem::filesystem_error &e) { Abort(e); } catch (boost::filesystem::filesystem_error &e) { Abort(e); }
} }
void TemporaryStorage::ReadFromSlot(const int slot_id, char *pointer, const std::size_t size) void TemporaryStorage::ReadFromSlot(const std::size_t slot_id, char *pointer, const std::size_t size)
{ {
try try
{ {

View File

@ -70,10 +70,10 @@ class TemporaryStorage
static TemporaryStorage &GetInstance(); static TemporaryStorage &GetInstance();
virtual ~TemporaryStorage(); virtual ~TemporaryStorage();
int AllocateSlot(); std::size_t AllocateSlot();
void DeallocateSlot(const int slot_id); void DeallocateSlot(const std::size_t slot_id);
void WriteToSlot(const int slot_id, char *pointer, const std::size_t size); void WriteToSlot(const std::size_t slot_id, char *pointer, const std::size_t size);
void ReadFromSlot(const int slot_id, char *pointer, const std::size_t size); void ReadFromSlot(const std::size_t slot_id, char *pointer, const std::size_t size);
// returns the number of free bytes // returns the number of free bytes
uint64_t GetFreeBytesOnTemporaryDevice(); uint64_t GetFreeBytesOnTemporaryDevice();
boost::filesystem::fstream::pos_type Tell(const int slot_id); boost::filesystem::fstream::pos_type Tell(const int slot_id);