db/upnp/WorkQueue: use emplace() and std::move()

This commit is contained in:
Max Kellermann 2014-01-16 08:45:55 +01:00
parent 028fd268b8
commit 478ace984a
1 changed files with 4 additions and 3 deletions

View File

@ -119,11 +119,12 @@ public:
*
* Sleeps if there are already too many.
*/
bool put(T t)
template<typename U>
bool put(U &&u)
{
const ScopeLock protect(mutex);
queue.push(t);
queue.emplace(std::forward<U>(u));
// Just wake one worker, there is only one new task.
worker_cond.signal();
@ -178,7 +179,7 @@ public:
return false;
}
tp = queue.front();
tp = std::move(queue.front());
queue.pop();
return true;
}