InputStream: add virtual destructor

Replaces the method Close().
This commit is contained in:
Max Kellermann
2014-05-11 16:59:19 +02:00
parent f1d0700252
commit 82337dec44
31 changed files with 48 additions and 180 deletions

View File

@@ -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()
{