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

Unified Diff: base/task_scheduler/scheduler_worker_pool_impl.h

Issue 2414063002: TaskScheduler: Always remove SchedulerWorker from idle stack on wake up. (Closed)
Patch Set: CR robliao #3 Created 4 years, 2 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 | base/task_scheduler/scheduler_worker_pool_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_worker_pool_impl.h
diff --git a/base/task_scheduler/scheduler_worker_pool_impl.h b/base/task_scheduler/scheduler_worker_pool_impl.h
index a621f797a53473b2096170a07689e456d5c3f2de..b5aa894e38afdaafce3c2933d46d4bf97ab7a6e3 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl.h
+++ b/base/task_scheduler/scheduler_worker_pool_impl.h
@@ -114,6 +114,9 @@ class BASE_EXPORT SchedulerWorkerPoolImpl : public SchedulerWorkerPool {
size_t max_threads,
const ReEnqueueSequenceCallback& re_enqueue_sequence_callback);
+ // Wakes up |worker|.
+ void WakeUpWorker(SchedulerWorker* worker);
+
// Wakes up the last worker from this worker pool to go idle, if any.
void WakeUpOneWorker();
@@ -159,7 +162,11 @@ class BASE_EXPORT SchedulerWorkerPoolImpl : public SchedulerWorkerPool {
// details in GetWork()).
mutable SchedulerLock idle_workers_stack_lock_;
- // Stack of idle workers.
+ // Stack of idle workers. Initially, all workers are on this stack. A worker
+ // is removed from the stack before its WakeUp() function is called and when
+ // it receives work from GetWork() (a worker calls GetWork() when its sleep
+ // timeout expires, even if its WakeUp() method hasn't been called). A worker
+ // is pushed on this stack when it receives nullptr from GetWork().
SchedulerWorkerStack idle_workers_stack_;
// Signaled when all workers become idle.
« no previous file with comments | « no previous file | base/task_scheduler/scheduler_worker_pool_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698