readBytes does not read bytes one by one but in chunks

This commit is contained in:
Benjamin Sergeant
2019-03-02 21:11:16 -08:00
parent a9e772f330
commit 0c226c7629
7 changed files with 49 additions and 49 deletions

View File

@ -10,6 +10,7 @@
#include <functional>
#include <mutex>
#include <atomic>
#include <vector>
#ifdef _WIN32
#include <BaseTsd.h>
@ -18,6 +19,7 @@ typedef SSIZE_T ssize_t;
#include "IXEventFd.h"
#include "IXCancellationRequest.h"
#include "IXProgressCallback.h"
namespace ix
{
@ -63,6 +65,7 @@ namespace ix
const CancellationRequest& isCancellationRequested);
std::pair<bool, std::string> readBytes(
size_t length,
const OnProgressCallback& onProgressCallback,
const CancellationRequest& isCancellationRequested);
static int getErrno();
@ -79,5 +82,9 @@ namespace ix
private:
static const int kDefaultPollTimeout;
static const int kDefaultPollNoTimeout;
// Buffer for reading from our socket. That buffer is never resized.
std::vector<uint8_t> _readBuffer;
static constexpr size_t kChunkSize = 1 << 15;
};
}