upnp/Discovery: use std::unique_ptr in WorkQueue

This commit is contained in:
Max Kellermann 2016-02-06 22:26:14 +01:00
parent 050c6cc4b0
commit 224d511616
2 changed files with 3 additions and 4 deletions

View File

@ -111,7 +111,7 @@ inline void
UPnPDeviceDirectory::Explore()
{
for (;;) {
DiscoveredTask *tsk = 0;
std::unique_ptr<DiscoveredTask> tsk;
if (!queue.take(tsk)) {
queue.workerExit();
return;
@ -138,14 +138,12 @@ UPnPDeviceDirectory::Explore()
Error error2;
bool success = d.Parse(tsk->url, buf, error2);
if (!success) {
delete tsk;
LogError(error2);
continue;
}
}
LockAdd(std::move(d));
delete tsk;
}
}

View File

@ -32,6 +32,7 @@
#include <list>
#include <vector>
#include <string>
#include <memory>
class ContentDirectoryService;
@ -97,7 +98,7 @@ class UPnPDeviceDirectory final : UpnpCallback {
Mutex mutex;
std::list<ContentDirectoryDescriptor> directories;
WorkQueue<DiscoveredTask *> queue;
WorkQueue<std::unique_ptr<DiscoveredTask>> queue;
/**
* The UPnP device search timeout, which should actually be