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

Unified Diff: base/threading/worker_pool_posix.h

Issue 8565024: base: Refactor PendingTask out of MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add new files. Created 9 years, 1 month 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/threading/worker_pool_posix.h
diff --git a/base/threading/worker_pool_posix.h b/base/threading/worker_pool_posix.h
index 2cc1150e1612a4b5748bd27b0a1b1974ab792775..48c08980008cb58dcce27855ac98002411d7fa90 100644
--- a/base/threading/worker_pool_posix.h
+++ b/base/threading/worker_pool_posix.h
@@ -34,6 +34,7 @@
#include "base/time.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/pending_task.h"
#include "base/synchronization/condition_variable.h"
#include "base/synchronization/lock.h"
#include "base/threading/platform_thread.h"
@@ -48,23 +49,6 @@ class BASE_EXPORT PosixDynamicThreadPool
public:
class PosixDynamicThreadPoolPeer;
- struct PendingTask {
- PendingTask(const tracked_objects::Location& posted_from,
- const base::Closure& task);
- ~PendingTask();
-
- // Counter for location where the Closure was posted from.
- tracked_objects::Births* birth_tally;
-
- // Time the task was posted.
- tracked_objects::TrackedTime time_posted;
-
- const tracked_objects::Location posted_from;
-
- // The task to run.
- base::Closure task;
- };
-
// All worker threads will share the same |name_prefix|. They will exit after
// |idle_seconds_before_exit|.
PosixDynamicThreadPool(const std::string& name_prefix,
@@ -88,14 +72,14 @@ class BASE_EXPORT PosixDynamicThreadPool
// Worker thread method to wait for up to |idle_seconds_before_exit| for more
// work from the thread pool. Returns NULL if no work is available.
- PendingTask WaitForTask();
+ base::PendingTask WaitForTask();
private:
friend class PosixDynamicThreadPoolPeer;
// Adds pending_task to the thread pool. This function will clear
// |pending_task->task|.
- void AddTask(PendingTask* pending_task);
+ void AddTask(base::PendingTask* pending_task);
const std::string name_prefix_;
const int idle_seconds_before_exit_;
@@ -107,7 +91,7 @@ class BASE_EXPORT PosixDynamicThreadPool
// is being deleted and they can exit.
ConditionVariable pending_tasks_available_cv_;
int num_idle_threads_;
- std::queue<PendingTask> pending_tasks_;
+ TaskQueue pending_tasks_;
bool terminated_;
// Only used for tests to ensure correct thread ordering. It will always be
// NULL in non-test code.

Powered by Google App Engine
This is Rietveld 408576698