summaryrefslogtreecommitdiff
path: root/src/input/ThreadInputStream.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/input/ThreadInputStream.hxx')
-rw-r--r--src/input/ThreadInputStream.hxx24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/input/ThreadInputStream.hxx b/src/input/ThreadInputStream.hxx
index cbf378926..4883dae24 100644
--- a/src/input/ThreadInputStream.hxx
+++ b/src/input/ThreadInputStream.hxx
@@ -24,14 +24,14 @@
#include "InputStream.hxx"
#include "thread/Thread.hxx"
#include "thread/Cond.hxx"
+#include "util/HugeAllocator.hxx"
+#include "util/CircularBuffer.hxx"
#include <exception>
#include <assert.h>
#include <stdint.h>
-template<typename T> class CircularBuffer;
-
/**
* Helper class for moving InputStream implementations with blocking
* backend library implementation to a dedicated thread. Data is
@@ -60,8 +60,9 @@ class ThreadInputStream : public InputStream {
std::exception_ptr postponed_exception;
- const size_t buffer_size;
- CircularBuffer<uint8_t> *buffer = nullptr;
+ HugeArray<uint8_t> allocation;
+
+ CircularBuffer<uint8_t> buffer;
/**
* Shall the stream be closed?
@@ -76,17 +77,12 @@ class ThreadInputStream : public InputStream {
public:
ThreadInputStream(const char *_plugin,
const char *_uri, Mutex &_mutex, Cond &_cond,
- size_t _buffer_size)
- :InputStream(_uri, _mutex, _cond),
- plugin(_plugin),
- thread(BIND_THIS_METHOD(ThreadFunc)),
- buffer_size(_buffer_size) {}
+ size_t _buffer_size) noexcept;
#ifndef NDEBUG
~ThreadInputStream() override {
/* Stop() must have been called already */
assert(!thread.IsDefined());
- assert(buffer == nullptr);
}
#endif
@@ -108,7 +104,7 @@ protected:
*/
void Stop() noexcept;
- void SetMimeType(const char *_mime) {
+ void SetMimeType(const char *_mime) noexcept {
assert(thread.IsInside());
InputStream::SetMimeType(_mime);
@@ -145,7 +141,7 @@ protected:
*
* The #InputStream is not locked.
*/
- virtual void Close() {}
+ virtual void Close() noexcept {}
/**
* Called from the client thread to cancel a Read() inside the
@@ -153,10 +149,10 @@ protected:
*
* The #InputStream is not locked.
*/
- virtual void Cancel() {}
+ virtual void Cancel() noexcept {}
private:
- void ThreadFunc();
+ void ThreadFunc() noexcept;
};
#endif