input/async: use class HugeAllocation

This commit is contained in:
Max Kellermann 2016-06-17 18:06:02 +02:00
parent 91769d536d
commit bdd0c3686d
4 changed files with 7 additions and 9 deletions

View File

@ -23,17 +23,17 @@
#include "tag/Tag.hxx"
#include "thread/Cond.hxx"
#include "IOThread.hxx"
#include "util/HugeAllocator.hxx"
#include <assert.h>
#include <string.h>
AsyncInputStream::AsyncInputStream(const char *_url,
Mutex &_mutex, Cond &_cond,
void *_buffer, size_t _buffer_size,
size_t _buffer_size,
size_t _resume_at)
:InputStream(_url, _mutex, _cond), DeferredMonitor(io_thread_get()),
buffer((uint8_t *)_buffer, _buffer_size),
allocation(_buffer_size),
buffer((uint8_t *)allocation.get(), _buffer_size),
resume_at(_resume_at),
open(true),
paused(false),
@ -45,7 +45,6 @@ AsyncInputStream::~AsyncInputStream()
delete tag;
buffer.Clear();
HugeFree(buffer.Write().data, buffer.GetCapacity());
}
void

View File

@ -22,6 +22,7 @@
#include "InputStream.hxx"
#include "event/DeferredMonitor.hxx"
#include "util/HugeAllocator.hxx"
#include "util/CircularBuffer.hxx"
#include "util/Error.hxx"
@ -36,6 +37,8 @@ class AsyncInputStream : public InputStream, private DeferredMonitor {
NONE, SCHEDULED, PENDING
};
HugeAllocation allocation;
CircularBuffer<uint8_t> buffer;
const size_t resume_at;
@ -68,7 +71,7 @@ public:
*/
AsyncInputStream(const char *_url,
Mutex &_mutex, Cond &_cond,
void *_buffer, size_t _buffer_size,
size_t _buffer_size,
size_t _resume_at);
virtual ~AsyncInputStream();

View File

@ -32,7 +32,6 @@
#include "util/ASCII.hxx"
#include "util/StringUtil.hxx"
#include "util/NumberParser.hxx"
#include "util/HugeAllocator.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "Log.hxx"
@ -75,7 +74,6 @@ struct CurlInputStream final : public AsyncInputStream {
CurlInputStream(const char *_url, Mutex &_mutex, Cond &_cond)
:AsyncInputStream(_url, _mutex, _cond,
HugeAllocate(CURL_MAX_BUFFERED),
CURL_MAX_BUFFERED,
CURL_RESUME_AT),
request_headers(nullptr),

View File

@ -24,7 +24,6 @@
#include "lib/nfs/Domain.hxx"
#include "lib/nfs/Glue.hxx"
#include "lib/nfs/FileReader.hxx"
#include "util/HugeAllocator.hxx"
#include "util/StringCompare.hxx"
#include "util/Error.hxx"
@ -50,7 +49,6 @@ class NfsInputStream final : public AsyncInputStream, NfsFileReader {
public:
NfsInputStream(const char *_uri, Mutex &_mutex, Cond &_cond)
:AsyncInputStream(_uri, _mutex, _cond,
HugeAllocate(NFS_MAX_BUFFERED),
NFS_MAX_BUFFERED,
NFS_RESUME_AT),
reconnect_on_resume(false), reconnecting(false) {}