From 82337dec44347017ca04fe975e85e6d9e4edb635 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 11 May 2014 16:59:19 +0200 Subject: InputStream: add virtual destructor Replaces the method Close(). --- src/input/ThreadInputStream.cxx | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'src/input/ThreadInputStream.cxx') diff --git a/src/input/ThreadInputStream.cxx b/src/input/ThreadInputStream.cxx index 0f503be3f..408b757f9 100644 --- a/src/input/ThreadInputStream.cxx +++ b/src/input/ThreadInputStream.cxx @@ -29,6 +29,15 @@ ThreadInputStream::~ThreadInputStream() { + Lock(); + close = true; + wake_cond.signal(); + Unlock(); + + Cancel(); + + thread.Join(); + if (buffer != nullptr) { buffer->Clear(); HugeFree(buffer->Write().data, buffer_size); @@ -172,28 +181,6 @@ ThreadInputStream::Read(InputStream *is, void *ptr, size_t size, return tis.Read2(ptr, size, error); } -inline void -ThreadInputStream::Close2() -{ - Lock(); - close = true; - wake_cond.signal(); - Unlock(); - - Cancel(); - - thread.Join(); - - delete this; -} - -void -ThreadInputStream::Close(InputStream *is) -{ - ThreadInputStream &tis = *(ThreadInputStream *)is; - tis.Close2(); -} - inline bool ThreadInputStream::IsEOF2() { -- cgit v1.2.3