db/upnp/WorkQueue: use emplace() and std::move()
This commit is contained in:
parent
028fd268b8
commit
478ace984a
|
@ -119,11 +119,12 @@ public:
|
||||||
*
|
*
|
||||||
* Sleeps if there are already too many.
|
* Sleeps if there are already too many.
|
||||||
*/
|
*/
|
||||||
bool put(T t)
|
template<typename U>
|
||||||
|
bool put(U &&u)
|
||||||
{
|
{
|
||||||
const ScopeLock protect(mutex);
|
const ScopeLock protect(mutex);
|
||||||
|
|
||||||
queue.push(t);
|
queue.emplace(std::forward<U>(u));
|
||||||
|
|
||||||
// Just wake one worker, there is only one new task.
|
// Just wake one worker, there is only one new task.
|
||||||
worker_cond.signal();
|
worker_cond.signal();
|
||||||
|
@ -178,7 +179,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp = queue.front();
|
tp = std::move(queue.front());
|
||||||
queue.pop();
|
queue.pop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue