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

Unified Diff: base/task_scheduler/scheduler_worker_pool_impl.cc

Issue 2464963002: TaskScheduler: Remove base::ExecutionMode. (Closed)
Patch Set: self-review Created 4 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/task_scheduler/scheduler_worker_pool_impl.cc
diff --git a/base/task_scheduler/scheduler_worker_pool_impl.cc b/base/task_scheduler/scheduler_worker_pool_impl.cc
index af6e92ff053b5b5fe6a7af7800bd110114b1791f..34de2ac586c1e49f66f8edb31ec764ae85ab0659 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl.cc
+++ b/base/task_scheduler/scheduler_worker_pool_impl.cc
@@ -16,8 +16,6 @@
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/sequence_token.h"
-#include "base/sequenced_task_runner.h"
-#include "base/single_thread_task_runner.h"
gab 2016/10/31 19:10:11 (but here you'll want to keep them since you're us
robliao 2016/10/31 19:19:59 Not sure I follow here. The style guide permits us
gab 2016/10/31 19:28:45 Right but my other comment asks to remove from hea
robliao 2016/10/31 19:31:48 Gotcha. That other comment makes a lot more sense
fdoray 2016/10/31 19:44:51 Done.
#include "base/strings/stringprintf.h"
#include "base/task_scheduler/delayed_task_manager.h"
#include "base/task_scheduler/task_tracker.h"
@@ -341,33 +339,31 @@ void SchedulerWorkerPoolImpl::DisallowWorkerDetachmentForTesting() {
}
scoped_refptr<TaskRunner> SchedulerWorkerPoolImpl::CreateTaskRunnerWithTraits(
- const TaskTraits& traits,
- ExecutionMode execution_mode) {
- switch (execution_mode) {
- case ExecutionMode::PARALLEL:
- return make_scoped_refptr(new SchedulerParallelTaskRunner(traits, this));
-
- case ExecutionMode::SEQUENCED:
- return make_scoped_refptr(new SchedulerSequencedTaskRunner(traits, this));
-
- case ExecutionMode::SINGLE_THREADED: {
- // TODO(fdoray): Find a way to take load into account when assigning a
- // SchedulerWorker to a SingleThreadTaskRunner. Also, this code
- // assumes that all SchedulerWorkers are alive. Eventually, we might
- // decide to tear down threads that haven't run tasks for a long time.
- size_t worker_index;
- {
- AutoSchedulerLock auto_lock(next_worker_index_lock_);
- worker_index = next_worker_index_;
- next_worker_index_ = (next_worker_index_ + 1) % workers_.size();
- }
- return make_scoped_refptr(new SchedulerSingleThreadTaskRunner(
- traits, this, workers_[worker_index].get()));
- }
- }
+ const TaskTraits& traits) {
+ return make_scoped_refptr(new SchedulerParallelTaskRunner(traits, this));
+}
- NOTREACHED();
- return nullptr;
+scoped_refptr<SequencedTaskRunner>
+SchedulerWorkerPoolImpl::CreateSequencedTaskRunnerWithTraits(
+ const TaskTraits& traits) {
+ return make_scoped_refptr(new SchedulerSequencedTaskRunner(traits, this));
+}
+
+scoped_refptr<SingleThreadTaskRunner>
+SchedulerWorkerPoolImpl::CreateSingleThreadTaskRunnerWithTraits(
+ const TaskTraits& traits) {
+ // TODO(fdoray): Find a way to take load into account when assigning a
+ // SchedulerWorker to a SingleThreadTaskRunner. Also, this code assumes that
+ // all SchedulerWorkers are alive. Eventually, we might decide to tear down
+ // threads that haven't run tasks for a long time.
gab 2016/10/31 19:10:11 The second half of this comment is wrong with deta
fdoray 2016/10/31 19:44:51 Removed second part of the comment since I don't b
+ size_t worker_index;
+ {
+ AutoSchedulerLock auto_lock(next_worker_index_lock_);
+ worker_index = next_worker_index_;
+ next_worker_index_ = (next_worker_index_ + 1) % workers_.size();
+ }
+ return make_scoped_refptr(new SchedulerSingleThreadTaskRunner(
+ traits, this, workers_[worker_index].get()));
}
void SchedulerWorkerPoolImpl::ReEnqueueSequence(

Powered by Google App Engine
This is Rietveld 408576698