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

View File

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