storage/curl: migrate from DeferredMonitor to DeferEvent

This commit is contained in:
Max Kellermann 2017-11-10 21:10:54 +01:00
parent 42ad753e39
commit ec20784046

View File

@ -31,7 +31,7 @@
#include "lib/expat/ExpatParser.hxx" #include "lib/expat/ExpatParser.hxx"
#include "fs/Traits.hxx" #include "fs/Traits.hxx"
#include "event/Call.hxx" #include "event/Call.hxx"
#include "event/DeferredMonitor.hxx" #include "event/DeferEvent.hxx"
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "util/ChronoUtil.hxx" #include "util/ChronoUtil.hxx"
@ -88,7 +88,9 @@ CurlStorage::MapToRelativeUTF8(const char *uri_utf8) const noexcept
return PathTraitsUTF8::Relative(base.c_str(), uri_utf8); return PathTraitsUTF8::Relative(base.c_str(), uri_utf8);
} }
class BlockingHttpRequest : protected CurlResponseHandler, DeferredMonitor { class BlockingHttpRequest : protected CurlResponseHandler {
DeferEvent defer_start;
std::exception_ptr postponed_error; std::exception_ptr postponed_error;
bool done = false; bool done = false;
@ -101,12 +103,13 @@ protected:
public: public:
BlockingHttpRequest(CurlGlobal &curl, const char *uri) BlockingHttpRequest(CurlGlobal &curl, const char *uri)
:DeferredMonitor(curl.GetEventLoop()), :defer_start(curl.GetEventLoop(),
BIND_THIS_METHOD(OnDeferredStart)),
request(curl, uri, *this) { request(curl, uri, *this) {
// TODO: use CurlInputStream's configuration // TODO: use CurlInputStream's configuration
/* start the transfer inside the IOThread */ /* start the transfer inside the IOThread */
DeferredMonitor::Schedule(); defer_start.Schedule();
} }
void Wait() { void Wait() {
@ -133,8 +136,8 @@ protected:
} }
private: private:
/* virtual methods from DeferredMonitor */ /* DeferEvent callback */
void RunDeferred() final { void OnDeferredStart() noexcept {
assert(!done); assert(!done);
request.Start(); request.Start();