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

Unified Diff: base/task_scheduler/scheduler_worker_stack.cc

Issue 2116163002: Add Lazy Creation and Thread Detachment Support in the Scheduler Worker Pool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fenced Load Created 4 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
Index: base/task_scheduler/scheduler_worker_stack.cc
diff --git a/base/task_scheduler/scheduler_worker_stack.cc b/base/task_scheduler/scheduler_worker_stack.cc
index 7746373aa664123921a1389eb6c30806c89b100e..7996efe5a398e33b4bb13375b926143c5021c9cb 100644
--- a/base/task_scheduler/scheduler_worker_stack.cc
+++ b/base/task_scheduler/scheduler_worker_stack.cc
@@ -16,8 +16,7 @@ SchedulerWorkerStack::SchedulerWorkerStack() = default;
SchedulerWorkerStack::~SchedulerWorkerStack() = default;
void SchedulerWorkerStack::Push(SchedulerWorker* worker) {
- DCHECK(std::find(stack_.begin(), stack_.end(), worker) == stack_.end())
- << "SchedulerWorker already on stack";
+ DCHECK(!Contains(worker)) << "SchedulerWorker already on stack";
stack_.push_back(worker);
}
@@ -29,6 +28,16 @@ SchedulerWorker* SchedulerWorkerStack::Pop() {
return worker;
}
+SchedulerWorker* SchedulerWorkerStack::Peek() const {
+ if (IsEmpty())
+ return nullptr;
+ return stack_.back();
+}
+
+bool SchedulerWorkerStack::Contains(const SchedulerWorker* worker) const {
+ return std::find(stack_.begin(), stack_.end(), worker) != stack_.end();
+}
+
void SchedulerWorkerStack::Remove(const SchedulerWorker* worker) {
auto it = std::find(stack_.begin(), stack_.end(), worker);
if (it != stack_.end())

Powered by Google App Engine
This is Rietveld 408576698