lib/upnp/Discovery: add method GetEventLoop()

This commit is contained in:
Max Kellermann 2017-08-25 10:59:49 +02:00
parent 309ed77ef4
commit 8aef518c05
2 changed files with 11 additions and 3 deletions

View File

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

View File

@ -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 */