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

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

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: fixed build error and commments Created 3 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 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/worker_pool.h" 5 #include "base/threading/worker_pool.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 29 matching lines...) Expand all
40 // 40 //
41 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner). 41 // Note that this class is RefCountedThreadSafe (inherited from TaskRunner).
42 class WorkerPoolTaskRunner : public TaskRunner { 42 class WorkerPoolTaskRunner : public TaskRunner {
43 public: 43 public:
44 explicit WorkerPoolTaskRunner(bool tasks_are_slow); 44 explicit WorkerPoolTaskRunner(bool tasks_are_slow);
45 45
46 // TaskRunner implementation 46 // TaskRunner implementation
47 bool PostDelayedTask(const tracked_objects::Location& from_here, 47 bool PostDelayedTask(const tracked_objects::Location& from_here,
48 OnceClosure task, 48 OnceClosure task,
49 TimeDelta delay) override; 49 TimeDelta delay) override;
50 bool RunsTasksOnCurrentThread() const override; 50 bool RunsTasksInCurrentSequence() const override;
51 51
52 private: 52 private:
53 ~WorkerPoolTaskRunner() override; 53 ~WorkerPoolTaskRunner() override;
54 54
55 // Helper function for posting a delayed task. Asserts that the delay is 55 // Helper function for posting a delayed task. Asserts that the delay is
56 // zero because non-zero delays are not supported. 56 // zero because non-zero delays are not supported.
57 bool PostDelayedTaskAssertZeroDelay( 57 bool PostDelayedTaskAssertZeroDelay(
58 const tracked_objects::Location& from_here, 58 const tracked_objects::Location& from_here,
59 OnceClosure task, 59 OnceClosure task,
60 base::TimeDelta delay); 60 base::TimeDelta delay);
(...skipping 10 matching lines...) Expand all
71 WorkerPoolTaskRunner::~WorkerPoolTaskRunner() { 71 WorkerPoolTaskRunner::~WorkerPoolTaskRunner() {
72 } 72 }
73 73
74 bool WorkerPoolTaskRunner::PostDelayedTask( 74 bool WorkerPoolTaskRunner::PostDelayedTask(
75 const tracked_objects::Location& from_here, 75 const tracked_objects::Location& from_here,
76 OnceClosure task, 76 OnceClosure task,
77 TimeDelta delay) { 77 TimeDelta delay) {
78 return PostDelayedTaskAssertZeroDelay(from_here, std::move(task), delay); 78 return PostDelayedTaskAssertZeroDelay(from_here, std::move(task), delay);
79 } 79 }
80 80
81 bool WorkerPoolTaskRunner::RunsTasksOnCurrentThread() const { 81 bool WorkerPoolTaskRunner::RunsTasksInCurrentSequence() const {
82 return WorkerPool::RunsTasksOnCurrentThread(); 82 return WorkerPool::RunsTasksOnCurrentThread();
83 } 83 }
84 84
85 bool WorkerPoolTaskRunner::PostDelayedTaskAssertZeroDelay( 85 bool WorkerPoolTaskRunner::PostDelayedTaskAssertZeroDelay(
86 const tracked_objects::Location& from_here, 86 const tracked_objects::Location& from_here,
87 OnceClosure task, 87 OnceClosure task,
88 base::TimeDelta delay) { 88 base::TimeDelta delay) {
89 DCHECK_EQ(delay.InMillisecondsRoundedUp(), 0) 89 DCHECK_EQ(delay.InMillisecondsRoundedUp(), 0)
90 << "WorkerPoolTaskRunner does not support non-zero delays"; 90 << "WorkerPoolTaskRunner does not support non-zero delays";
91 return WorkerPool::PostTask(from_here, std::move(task), tasks_are_slow_); 91 return WorkerPool::PostTask(from_here, std::move(task), tasks_are_slow_);
(...skipping 24 matching lines...) Expand all
116 } 116 }
117 117
118 // static 118 // static
119 const scoped_refptr<TaskRunner>& 119 const scoped_refptr<TaskRunner>&
120 WorkerPool::GetTaskRunner(bool tasks_are_slow) { 120 WorkerPool::GetTaskRunner(bool tasks_are_slow) {
121 static auto* task_runner_holder = new TaskRunnerHolder(); 121 static auto* task_runner_holder = new TaskRunnerHolder();
122 return task_runner_holder->taskrunners_[tasks_are_slow]; 122 return task_runner_holder->taskrunners_[tasks_are_slow];
123 } 123 }
124 124
125 } // namespace base 125 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698