add buffering to temporary storage
This commit is contained in:
parent
f0fb97e67c
commit
682079adc6
@ -63,12 +63,11 @@ public:
|
|||||||
|
|
||||||
int AllocateSlot();
|
int AllocateSlot();
|
||||||
void DeallocateSlot(const int slot_id);
|
void DeallocateSlot(const int slot_id);
|
||||||
void WriteToSlot(const int slot_id, char * pointer, std::streamsize size);
|
void WriteToSlot(const int slot_id, char * pointer, const std::size_t size);
|
||||||
void ReadFromSlot(const int slot_id, char * pointer, std::streamsize size);
|
void ReadFromSlot(const int 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(int slot_id);
|
boost::filesystem::fstream::pos_type Tell(const int slot_id);
|
||||||
void Seek(const int slot_id, boost::filesystem::fstream::pos_type);
|
|
||||||
void RemoveAll();
|
void RemoveAll();
|
||||||
private:
|
private:
|
||||||
TemporaryStorage();
|
TemporaryStorage();
|
||||||
@ -78,7 +77,7 @@ private:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Abort(boost::filesystem::filesystem_error& e);
|
void Abort(const boost::filesystem::filesystem_error& e);
|
||||||
void CheckIfTemporaryDeviceFull();
|
void CheckIfTemporaryDeviceFull();
|
||||||
|
|
||||||
struct StreamData {
|
struct StreamData {
|
||||||
@ -86,6 +85,8 @@ private:
|
|||||||
boost::filesystem::path temp_path;
|
boost::filesystem::path temp_path;
|
||||||
boost::shared_ptr<boost::filesystem::fstream> temp_file;
|
boost::shared_ptr<boost::filesystem::fstream> temp_file;
|
||||||
boost::shared_ptr<boost::mutex> readWriteMutex;
|
boost::shared_ptr<boost::mutex> readWriteMutex;
|
||||||
|
std::vector<char> buffer;
|
||||||
|
|
||||||
StreamData() :
|
StreamData() :
|
||||||
write_mode(true),
|
write_mode(true),
|
||||||
temp_path(
|
temp_path(
|
||||||
@ -104,14 +105,14 @@ private:
|
|||||||
),
|
),
|
||||||
readWriteMutex(boost::make_shared<boost::mutex>())
|
readWriteMutex(boost::make_shared<boost::mutex>())
|
||||||
{
|
{
|
||||||
if(temp_file->fail()) {
|
if( temp_file->fail() ) {
|
||||||
throw OSRMException("temporary file could not be created");
|
throw OSRMException("temporary file could not be created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//vector of file streams that is used to store temporary data
|
//vector of file streams that is used to store temporary data
|
||||||
std::vector<StreamData> stream_data_list;
|
|
||||||
boost::mutex mutex;
|
boost::mutex mutex;
|
||||||
|
std::vector<StreamData> stream_data_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TEMPORARYSTORAGE_H_ */
|
#endif /* TEMPORARYSTORAGE_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user