From 8aef518c05bc7e3e837ec1531e419aa49ebfca71 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 25 Aug 2017 10:59:49 +0200 Subject: [PATCH] lib/upnp/Discovery: add method GetEventLoop() --- src/lib/upnp/Discovery.cxx | 12 +++++++++--- src/lib/upnp/Discovery.hxx | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index 8dc0b96ad..2d2f4ff02 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -45,7 +45,7 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent, void UPnPDeviceDirectory::Downloader::Start() { - auto &event_loop = parent.curl->GetEventLoop(); + auto &event_loop = parent.GetEventLoop(); BlockingCall(event_loop, [this](){ request.Start(); @@ -187,7 +187,7 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco) try { downloader->Start(); } catch (...) { - BlockingCall(curl->GetEventLoop(), [downloader](){ + BlockingCall(GetEventLoop(), [downloader](){ downloader->Destroy(); }); @@ -267,11 +267,17 @@ UPnPDeviceDirectory::UPnPDeviceDirectory(EventLoop &event_loop, UPnPDeviceDirectory::~UPnPDeviceDirectory() { - BlockingCall(curl->GetEventLoop(), [this](){ + BlockingCall(GetEventLoop(), [this](){ downloaders.clear_and_dispose(DeleteDisposer()); }); } +inline EventLoop & +UPnPDeviceDirectory::GetEventLoop() +{ + return curl->GetEventLoop(); +} + void UPnPDeviceDirectory::Start() { diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index e61f1e399..2e59be3c4 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -143,6 +143,8 @@ public: UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete; UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete; + EventLoop &GetEventLoop(); + void Start(); /** Retrieve the directory services currently seen on the network */