Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: webrtc/rtc_base/task_queue.h

Issue 3006933002: Allow PostTask() to take unique_ptr to classes derived of QueuedTask (Closed)
Patch Set: . Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/rtc_base/task_queue.h
diff --git a/webrtc/rtc_base/task_queue.h b/webrtc/rtc_base/task_queue.h
index e7eac2f18535ac7030d8c810b11fbf7c1d777800..0d9630bbf4f1e824a9f93b95d39c9db8dae72981 100644
--- a/webrtc/rtc_base/task_queue.h
+++ b/webrtc/rtc_base/task_queue.h
@@ -14,6 +14,7 @@
#include <list>
#include <memory>
#include <queue>
+#include <type_traits>
#if defined(WEBRTC_MAC)
#include <dispatch/dispatch.h>
@@ -189,7 +190,12 @@ class LOCKABLE TaskQueue {
// more likely). This can be mitigated by limiting the use of delayed tasks.
void PostDelayedTask(std::unique_ptr<QueuedTask> task, uint32_t milliseconds);
- template <class Closure>
+ // std::enable_if is used here to make sure that calls to PostTask() with
+ // std::unique_ptr<SomeClassDerivedFromQueuedTask> would not end up being
+ // caught by this template.
+ template <class Closure,
+ typename std::enable_if<
+ std::is_copy_constructible<Closure>::value>::type* = nullptr>
void PostTask(const Closure& closure) {
PostTask(std::unique_ptr<QueuedTask>(new ClosureTask<Closure>(closure)));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698