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

Unified Diff: base/task_scheduler/scheduler_thread_pool.h

Issue 1895513002: TaskScheduler [12] Support SINGLE_THREADED in SchedulerThreadPool DO NOT SUBMIT (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@10_superstack
Patch Set: 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
Index: base/task_scheduler/scheduler_thread_pool.h
diff --git a/base/task_scheduler/scheduler_thread_pool.h b/base/task_scheduler/scheduler_thread_pool.h
index 75c8a3290cfbc2cb9c2a60a6a40ef8510a841b13..bfe956f2c235642c041b0a744dd438b7b88be420 100644
--- a/base/task_scheduler/scheduler_thread_pool.h
+++ b/base/task_scheduler/scheduler_thread_pool.h
@@ -19,6 +19,7 @@
#include "base/task_runner.h"
#include "base/task_scheduler/priority_queue.h"
#include "base/task_scheduler/scheduler_lock.h"
+#include "base/task_scheduler/scheduler_stack.h"
#include "base/task_scheduler/scheduler_task_executor.h"
#include "base/task_scheduler/scheduler_worker_thread.h"
#include "base/task_scheduler/sequence.h"
@@ -97,9 +98,8 @@ class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor {
// Adds |worker_thread| to |idle_worker_threads_stack_|.
void AddToIdleWorkerThreadsStack(SchedulerWorkerThread* worker_thread);
- // Pops one idle worker thread from |idle_worker_thread_stack_| and returns
- // it. Returns nullptr if |idle_worker_thread_stack_| is empty.
- SchedulerWorkerThread* PopOneIdleWorkerThread();
+ // Removes |worker_thread| from |idle_worker_threads_stack_|.
+ void RemoveFromIdleWorkerThreadsStack(SchedulerWorkerThread* worker_thread);
// PriorityQueue from which all threads of this thread pool get work.
PriorityQueue shared_priority_queue_;
@@ -108,6 +108,9 @@ class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor {
// initialization of the thread pool.
std::vector<std::unique_ptr<SchedulerWorkerThread>> worker_threads_;
+ // Synchronizes the creation of SINGLE_THREADED TaskRunners.
+ SchedulerLock single_thread_task_runner_creation_lock_;
+
// Synchronizes access to |idle_worker_threads_stack_| and
// |idle_worker_threads_stack_cv_for_testing_|. Has |shared_priority_queue_|'s
// lock as its predecessor so that a thread can be pushed to
@@ -116,7 +119,7 @@ class BASE_EXPORT SchedulerThreadPool : public SchedulerTaskExecutor {
SchedulerLock idle_worker_threads_stack_lock_;
// Stack of idle worker threads.
- std::stack<SchedulerWorkerThread*> idle_worker_threads_stack_;
+ SchedulerStack<SchedulerWorkerThread*> idle_worker_threads_stack_;
// Signaled when all worker threads become idle.
std::unique_ptr<ConditionVariable> idle_worker_threads_stack_cv_for_testing_;
« no previous file with comments | « no previous file | base/task_scheduler/scheduler_thread_pool.cc » ('j') | base/task_scheduler/scheduler_thread_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698