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

Side by Side Diff: base/threading/sequenced_worker_pool.cc

Issue 2464963002: TaskScheduler: Remove base::ExecutionMode. (Closed)
Patch Set: CR robliao #10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 841
842 scoped_refptr<TaskRunner>& task_runner = 842 scoped_refptr<TaskRunner>& task_runner =
843 sequence_token_id ? sequenced_task_runner_map_[sequence_token_id] 843 sequence_token_id ? sequenced_task_runner_map_[sequence_token_id]
844 : unsequenced_task_runners_[static_cast<int>( 844 : unsequenced_task_runners_[static_cast<int>(
845 traits.shutdown_behavior())]; 845 traits.shutdown_behavior())];
846 846
847 // TODO(fdoray): DCHECK that all tasks posted to the same sequence have the 847 // TODO(fdoray): DCHECK that all tasks posted to the same sequence have the
848 // same shutdown behavior. 848 // same shutdown behavior.
849 849
850 if (!task_runner) { 850 if (!task_runner) {
851 ExecutionMode execution_mode = 851 task_runner = sequence_token_id
852 sequence_token_id ? ExecutionMode::SEQUENCED : ExecutionMode::PARALLEL; 852 ? CreateSequencedTaskRunnerWithTraits(traits)
853 task_runner = CreateTaskRunnerWithTraits(traits, execution_mode); 853 : CreateTaskRunnerWithTraits(traits);
854 } 854 }
855 855
856 return task_runner; 856 return task_runner;
857 } 857 }
858 858
859 bool SequencedWorkerPool::Inner::RunsTasksOnCurrentThread() const { 859 bool SequencedWorkerPool::Inner::RunsTasksOnCurrentThread() const {
860 AutoLock lock(lock_); 860 AutoLock lock(lock_);
861 if (subtle::NoBarrier_Load(&g_all_pools_state) == 861 if (subtle::NoBarrier_Load(&g_all_pools_state) ==
862 AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) { 862 AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER) {
863 if (!runs_tasks_on_verifier_) { 863 if (!runs_tasks_on_verifier_) {
864 runs_tasks_on_verifier_ = CreateTaskRunnerWithTraits( 864 runs_tasks_on_verifier_ = CreateTaskRunnerWithTraits(
865 TaskTraits().WithFileIO().WithPriority(task_priority_), 865 TaskTraits().WithFileIO().WithPriority(task_priority_));
866 ExecutionMode::PARALLEL);
867 } 866 }
868 return runs_tasks_on_verifier_->RunsTasksOnCurrentThread(); 867 return runs_tasks_on_verifier_->RunsTasksOnCurrentThread();
869 } else { 868 } else {
870 return ContainsKey(threads_, PlatformThread::CurrentId()); 869 return ContainsKey(threads_, PlatformThread::CurrentId());
871 } 870 }
872 } 871 }
873 872
874 bool SequencedWorkerPool::Inner::IsRunningSequenceOnCurrentThread( 873 bool SequencedWorkerPool::Inner::IsRunningSequenceOnCurrentThread(
875 SequenceToken sequence_token) const { 874 SequenceToken sequence_token) const {
876 DCHECK(sequence_token.IsValid()); 875 DCHECK(sequence_token.IsValid());
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 bool SequencedWorkerPool::IsShutdownInProgress() { 1616 bool SequencedWorkerPool::IsShutdownInProgress() {
1618 return inner_->IsShutdownInProgress(); 1617 return inner_->IsShutdownInProgress();
1619 } 1618 }
1620 1619
1621 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread( 1620 bool SequencedWorkerPool::IsRunningSequenceOnCurrentThread(
1622 SequenceToken sequence_token) const { 1621 SequenceToken sequence_token) const {
1623 return inner_->IsRunningSequenceOnCurrentThread(sequence_token); 1622 return inner_->IsRunningSequenceOnCurrentThread(sequence_token);
1624 } 1623 }
1625 1624
1626 } // namespace base 1625 } // namespace base
OLDNEW
« base/task_scheduler/test_utils.h ('K') | « base/task_scheduler/test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698