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

Unified Diff: base/task.cc

Issue 7316015: Support Closure in ALL the loops! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed nit and rebased. Created 9 years, 5 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 | « base/task.h ('k') | base/threading/worker_pool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task.cc
diff --git a/base/task.cc b/base/task.cc
index e4da5474a0098d852963c1ca5c1b350ffa306d37..8c614734863fb5c8e34959dd2b00b4ac8c80e538 100644
--- a/base/task.cc
+++ b/base/task.cc
@@ -34,4 +34,33 @@ Task* ScopedTaskRunner::Release() {
return tmp;
}
+namespace subtle {
+
+TaskClosureAdapter::TaskClosureAdapter(Task* task)
+ : task_(task),
+ should_leak_task_(&kTaskLeakingDefault) {
+}
+
+TaskClosureAdapter::TaskClosureAdapter(Task* task, bool* should_leak_task)
+ : task_(task),
+ should_leak_task_(should_leak_task) {
+}
+
+TaskClosureAdapter::~TaskClosureAdapter() {
+ if (!*should_leak_task_) {
+ delete task_;
+ }
+}
+
+void TaskClosureAdapter::Run() {
+ task_->Run();
+ delete task_;
+ task_ = NULL;
+}
+
+// Don't leak tasks by default.
+bool TaskClosureAdapter::kTaskLeakingDefault = false;
+
+} // namespace subtle
+
} // namespace base
« no previous file with comments | « base/task.h ('k') | base/threading/worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698