input/async: use class HugeAllocation
This commit is contained in:
parent
91769d536d
commit
bdd0c3686d
@ -23,17 +23,17 @@
|
|||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
#include "thread/Cond.hxx"
|
#include "thread/Cond.hxx"
|
||||||
#include "IOThread.hxx"
|
#include "IOThread.hxx"
|
||||||
#include "util/HugeAllocator.hxx"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
AsyncInputStream::AsyncInputStream(const char *_url,
|
AsyncInputStream::AsyncInputStream(const char *_url,
|
||||||
Mutex &_mutex, Cond &_cond,
|
Mutex &_mutex, Cond &_cond,
|
||||||
void *_buffer, size_t _buffer_size,
|
size_t _buffer_size,
|
||||||
size_t _resume_at)
|
size_t _resume_at)
|
||||||
:InputStream(_url, _mutex, _cond), DeferredMonitor(io_thread_get()),
|
: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),
|
resume_at(_resume_at),
|
||||||
open(true),
|
open(true),
|
||||||
paused(false),
|
paused(false),
|
||||||
@ -45,7 +45,6 @@ AsyncInputStream::~AsyncInputStream()
|
|||||||
delete tag;
|
delete tag;
|
||||||
|
|
||||||
buffer.Clear();
|
buffer.Clear();
|
||||||
HugeFree(buffer.Write().data, buffer.GetCapacity());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "InputStream.hxx"
|
#include "InputStream.hxx"
|
||||||
#include "event/DeferredMonitor.hxx"
|
#include "event/DeferredMonitor.hxx"
|
||||||
|
#include "util/HugeAllocator.hxx"
|
||||||
#include "util/CircularBuffer.hxx"
|
#include "util/CircularBuffer.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
|
||||||
@ -36,6 +37,8 @@ class AsyncInputStream : public InputStream, private DeferredMonitor {
|
|||||||
NONE, SCHEDULED, PENDING
|
NONE, SCHEDULED, PENDING
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HugeAllocation allocation;
|
||||||
|
|
||||||
CircularBuffer<uint8_t> buffer;
|
CircularBuffer<uint8_t> buffer;
|
||||||
const size_t resume_at;
|
const size_t resume_at;
|
||||||
|
|
||||||
@ -68,7 +71,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
AsyncInputStream(const char *_url,
|
AsyncInputStream(const char *_url,
|
||||||
Mutex &_mutex, Cond &_cond,
|
Mutex &_mutex, Cond &_cond,
|
||||||
void *_buffer, size_t _buffer_size,
|
size_t _buffer_size,
|
||||||
size_t _resume_at);
|
size_t _resume_at);
|
||||||
|
|
||||||
virtual ~AsyncInputStream();
|
virtual ~AsyncInputStream();
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/StringUtil.hxx"
|
#include "util/StringUtil.hxx"
|
||||||
#include "util/NumberParser.hxx"
|
#include "util/NumberParser.hxx"
|
||||||
#include "util/HugeAllocator.hxx"
|
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
@ -75,7 +74,6 @@ struct CurlInputStream final : public AsyncInputStream {
|
|||||||
|
|
||||||
CurlInputStream(const char *_url, Mutex &_mutex, Cond &_cond)
|
CurlInputStream(const char *_url, Mutex &_mutex, Cond &_cond)
|
||||||
:AsyncInputStream(_url, _mutex, _cond,
|
:AsyncInputStream(_url, _mutex, _cond,
|
||||||
HugeAllocate(CURL_MAX_BUFFERED),
|
|
||||||
CURL_MAX_BUFFERED,
|
CURL_MAX_BUFFERED,
|
||||||
CURL_RESUME_AT),
|
CURL_RESUME_AT),
|
||||||
request_headers(nullptr),
|
request_headers(nullptr),
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "lib/nfs/Domain.hxx"
|
#include "lib/nfs/Domain.hxx"
|
||||||
#include "lib/nfs/Glue.hxx"
|
#include "lib/nfs/Glue.hxx"
|
||||||
#include "lib/nfs/FileReader.hxx"
|
#include "lib/nfs/FileReader.hxx"
|
||||||
#include "util/HugeAllocator.hxx"
|
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
|
||||||
@ -50,7 +49,6 @@ class NfsInputStream final : public AsyncInputStream, NfsFileReader {
|
|||||||
public:
|
public:
|
||||||
NfsInputStream(const char *_uri, Mutex &_mutex, Cond &_cond)
|
NfsInputStream(const char *_uri, Mutex &_mutex, Cond &_cond)
|
||||||
:AsyncInputStream(_uri, _mutex, _cond,
|
:AsyncInputStream(_uri, _mutex, _cond,
|
||||||
HugeAllocate(NFS_MAX_BUFFERED),
|
|
||||||
NFS_MAX_BUFFERED,
|
NFS_MAX_BUFFERED,
|
||||||
NFS_RESUME_AT),
|
NFS_RESUME_AT),
|
||||||
reconnect_on_resume(false), reconnecting(false) {}
|
reconnect_on_resume(false), reconnecting(false) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user