From ecbad638f16b0f63c0be4fc43531ff0e50304d11 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 25 Jan 2017 23:15:52 +0100 Subject: [PATCH] input/async: add method GetEventLoop() --- src/input/AsyncInputStream.hxx | 4 ++++ src/input/plugins/CurlInputPlugin.cxx | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/input/AsyncInputStream.hxx b/src/input/AsyncInputStream.hxx index 32072d219..dad8899ad 100644 --- a/src/input/AsyncInputStream.hxx +++ b/src/input/AsyncInputStream.hxx @@ -80,6 +80,10 @@ public: virtual ~AsyncInputStream(); + EventLoop &GetEventLoop() { + return deferred_resume.GetEventLoop(); + } + /* virtual methods from InputStream */ void Check() final; bool IsEOF() final; diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index b972876a0..1e8bff0e9 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -31,6 +31,7 @@ #include "config/Block.hxx" #include "tag/TagBuilder.hxx" #include "event/Call.hxx" +#include "event/Loop.hxx" #include "IOThread.hxx" #include "util/ASCII.hxx" #include "util/StringUtil.hxx" @@ -137,7 +138,7 @@ static constexpr Domain curl_domain("curl"); void CurlInputStream::DoResume() { - assert(io_thread_inside()); + assert(GetEventLoop().IsInside()); mutex.unlock(); request->Resume(); @@ -147,7 +148,7 @@ CurlInputStream::DoResume() void CurlInputStream::FreeEasy() { - assert(io_thread_inside()); + assert(GetEventLoop().IsInside()); if (request == nullptr) return; @@ -161,7 +162,7 @@ CurlInputStream::FreeEasy() void CurlInputStream::FreeEasyIndirect() { - BlockingCall(io_thread_get(), [this](){ + BlockingCall(GetEventLoop(), [this](){ FreeEasy(); curl_global->InvalidateSockets(); }); @@ -171,7 +172,7 @@ void CurlInputStream::OnHeaders(unsigned status, std::multimap &&headers) { - assert(io_thread_inside()); + assert(GetEventLoop().IsInside()); assert(!postponed_exception); if (status < 200 || status >= 300) @@ -410,7 +411,7 @@ CurlInputStream::DoSeek(offset_type new_offset) const ScopeUnlock unlock(mutex); - BlockingCall(io_thread_get(), [this, new_offset](){ + BlockingCall(GetEventLoop(), [this, new_offset](){ SeekInternal(new_offset); }); } @@ -421,7 +422,7 @@ CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond) CurlInputStream *c = new CurlInputStream(url, mutex, cond); try { - BlockingCall(io_thread_get(), [c](){ + BlockingCall(c->GetEventLoop(), [c](){ c->InitEasy(); }); } catch (...) {