From 6fa403edd9a31132b94333d93fb6c3555d3ae0d7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 21 Sep 2017 22:53:57 +0200 Subject: [PATCH] lib/upnp/Discovery: migrate from DeferredMonitor to DeferEvent --- src/lib/upnp/Discovery.cxx | 10 +++------- src/lib/upnp/Discovery.hxx | 13 ++++++++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index baa9f9209..02effb437 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -34,7 +34,9 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent, const Upnp_Discovery &disco) - :DeferredMonitor(_parent.GetEventLoop()), parent(_parent), + :defer_start_event(_parent.GetEventLoop(), + BIND_THIS_METHOD(OnDeferredStart)), + parent(_parent), id(disco.DeviceId), url(disco.Location), expires(std::chrono::seconds(disco.Expires)), request(*parent.curl, url.c_str(), *this) @@ -49,12 +51,6 @@ UPnPDeviceDirectory::Downloader::Destroy() DeleteDisposer()); } -void -UPnPDeviceDirectory::Downloader::RunDeferred() -{ - request.Start(); -} - void UPnPDeviceDirectory::Downloader::OnHeaders(unsigned status, std::multimap &&) diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index f34bc3c39..55d43c72c 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -26,7 +26,7 @@ #include "lib/curl/Handler.hxx" #include "lib/curl/Request.hxx" #include "thread/Mutex.hxx" -#include "event/DeferredMonitor.hxx" +#include "event/DeferEvent.hxx" #include "Compiler.h" #include @@ -84,7 +84,9 @@ class UPnPDeviceDirectory final : UpnpCallback { class Downloader final : public boost::intrusive::list_base_hook>, - DeferredMonitor, CurlResponseHandler { + CurlResponseHandler { + + DeferEvent defer_start_event; UPnPDeviceDirectory &parent; @@ -101,14 +103,15 @@ class UPnPDeviceDirectory final : UpnpCallback { const Upnp_Discovery &disco); void Start() { - DeferredMonitor::Schedule(); + defer_start_event.Schedule(); } void Destroy(); private: - /* virtual methods from DeferredMonitor */ - void RunDeferred() override; + void OnDeferredStart() { + request.Start(); + } /* virtual methods from CurlResponseHandler */ void OnHeaders(unsigned status,