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

Unified Diff: base/task_scheduler/scheduler_thread_pool.cc

Issue 1892033003: TaskScheduler [10] SchedulerWorkerThreadStack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@9_single_thread
Patch Set: CR danakj #44 (Empty -> IsEmpty) Created 4 years, 8 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_scheduler/scheduler_thread_pool.h ('k') | base/task_scheduler/scheduler_worker_thread_stack.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_thread_pool.cc
diff --git a/base/task_scheduler/scheduler_thread_pool.cc b/base/task_scheduler/scheduler_thread_pool.cc
index a6ee6bad9074fe14e9d6f99080776d64bf517961..6e14638da37077aa04df244f182fba3e917a6875 100644
--- a/base/task_scheduler/scheduler_thread_pool.cc
+++ b/base/task_scheduler/scheduler_thread_pool.cc
@@ -204,7 +204,7 @@ void SchedulerThreadPool::EnqueueSequence(
void SchedulerThreadPool::WaitForAllWorkerThreadsIdleForTesting() {
AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_);
- while (idle_worker_threads_stack_.size() < worker_threads_.size())
+ while (idle_worker_threads_stack_.Size() < worker_threads_.size())
idle_worker_threads_stack_cv_for_testing_->Wait();
}
@@ -308,7 +308,7 @@ bool SchedulerThreadPool::Initialize(ThreadPriority thread_priority,
thread_priority, worker_thread_delegate_.get(), task_tracker_);
if (!worker_thread)
break;
- idle_worker_threads_stack_.push(worker_thread.get());
+ idle_worker_threads_stack_.Push(worker_thread.get());
worker_threads_.push_back(std::move(worker_thread));
}
@@ -316,7 +316,11 @@ bool SchedulerThreadPool::Initialize(ThreadPriority thread_priority,
}
void SchedulerThreadPool::WakeUpOneThread() {
- SchedulerWorkerThread* worker_thread = PopOneIdleWorkerThread();
+ SchedulerWorkerThread* worker_thread;
+ {
+ AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_);
+ worker_thread = idle_worker_threads_stack_.Pop();
+ }
if (worker_thread)
worker_thread->WakeUp();
}
@@ -324,23 +328,12 @@ void SchedulerThreadPool::WakeUpOneThread() {
void SchedulerThreadPool::AddToIdleWorkerThreadsStack(
SchedulerWorkerThread* worker_thread) {
AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_);
- idle_worker_threads_stack_.push(worker_thread);
- DCHECK_LE(idle_worker_threads_stack_.size(), worker_threads_.size());
+ idle_worker_threads_stack_.Push(worker_thread);
+ DCHECK_LE(idle_worker_threads_stack_.Size(), worker_threads_.size());
- if (idle_worker_threads_stack_.size() == worker_threads_.size())
+ if (idle_worker_threads_stack_.Size() == worker_threads_.size())
idle_worker_threads_stack_cv_for_testing_->Broadcast();
}
-SchedulerWorkerThread* SchedulerThreadPool::PopOneIdleWorkerThread() {
- AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_);
-
- if (idle_worker_threads_stack_.empty())
- return nullptr;
-
- auto worker_thread = idle_worker_threads_stack_.top();
- idle_worker_threads_stack_.pop();
- return worker_thread;
-}
-
} // namespace internal
} // namespace base
« no previous file with comments | « base/task_scheduler/scheduler_thread_pool.h ('k') | base/task_scheduler/scheduler_worker_thread_stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698