mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 03:20:11 +01:00
enh(FileStream): Add FileStreamBuf::resizeBuffer to set larger internal buffers. (#4621)
Larger buffers improve performance significantly when streaming large quantity of data on very fast devices.
This commit is contained in:
@@ -36,7 +36,7 @@ public:
|
||||
FileStreamBuf();
|
||||
/// Creates a FileStreamBuf.
|
||||
|
||||
~FileStreamBuf();
|
||||
~FileStreamBuf() override;
|
||||
/// Destroys the FileStream.
|
||||
|
||||
void open(const std::string& path, std::ios::openmode mode);
|
||||
@@ -49,10 +49,16 @@ public:
|
||||
/// Closes the File stream buffer. Returns true if successful,
|
||||
/// false otherwise.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
bool resizeBuffer(std::streamsize bufferSize) override;
|
||||
/// Resizes internal buffer. Minimum size is BUFFER_SIZE.
|
||||
/// Minimum is used when requested size is smaller.
|
||||
/// Buffer can be resized only when the file is not open.
|
||||
/// Returns true if resize succeeded.
|
||||
|
||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out) override;
|
||||
/// Change position by offset, according to way and mode.
|
||||
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out) override;
|
||||
/// Change to specified position, according to mode.
|
||||
|
||||
void flushToDisk();
|
||||
@@ -70,13 +76,13 @@ protected:
|
||||
BUFFER_SIZE = 4096
|
||||
};
|
||||
|
||||
int readFromDevice(char* buffer, std::streamsize length);
|
||||
int writeToDevice(const char* buffer, std::streamsize length);
|
||||
int readFromDevice(char* buffer, std::streamsize length) override;
|
||||
int writeToDevice(const char* buffer, std::streamsize length) override;
|
||||
|
||||
private:
|
||||
std::string _path;
|
||||
NativeHandle _fd;
|
||||
std::streamoff _pos;
|
||||
std::streamoff _pos {0};
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user