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

Unified Diff: base/worker_pool.h

Issue 6094005: Create "Prebind" a wrapper to tr1::bind. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Remove closure.h and ThunkState Created 9 years, 12 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
Index: base/worker_pool.h
diff --git a/base/worker_pool.h b/base/worker_pool.h
index e0b75a9a753ad1169a16cea9cbb2de6c9295131e..de3ac3dc7ce0f753e22b96a9d7d214560eeee8ab 100644
--- a/base/worker_pool.h
+++ b/base/worker_pool.h
@@ -7,6 +7,8 @@
#pragma once
#include "base/tracked.h"
+#include "base/prebind.h"
+#include "base/task.h"
class Task;
@@ -26,6 +28,30 @@ class WorkerPool {
// return value, ownership of |task| is transferred to the worker pool.
static bool PostTask(const tracked_objects::Location& from_here,
Task* task, bool task_is_slow);
+ static bool PostThunk(const tracked_objects::Location& from_here,
+ base::Thunk<void(void)> thunk, bool task_is_slow) {
+ // The wrapping of Closure in Task will screw up task tracking...that will
+ // be fixed if we actually wave the Closure class through the API
+ // correctly.
+ return PostTask(from_here, new ThunkTaskAdapter(thunk), task_is_slow);
+ }
+
+private:
+ // This is a complete hack just for the proof of concept. Really, we want
+ // to modify PendingTask to understand base::Closure.
+ class ThunkTaskAdapter : public Task {
+ public:
+ explicit ThunkTaskAdapter(base::Thunk<void(void)> t)
+ : thunk_(t) {
+ }
+
+ virtual void Run() {
+ thunk_();
+ }
+
+ private:
+ base::Thunk<void(void)> thunk_;
+ };
};
#endif // BASE_WORKER_POOL_H_

Powered by Google App Engine
This is Rietveld 408576698