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

Side by Side Diff: base/task_scheduler/scheduler_thread_pool_impl.cc

Issue 1906813003: TaskScheduler: TimeDelta instead of TimeTicks in Task's constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sched_2c_owned_delegate
Patch Set: rebase Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/task_scheduler/scheduler_thread_pool_impl.h" 5 #include "base/task_scheduler/scheduler_thread_pool_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 23 matching lines...) Expand all
34 SchedulerParallelTaskRunner(const TaskTraits& traits, 34 SchedulerParallelTaskRunner(const TaskTraits& traits,
35 SchedulerThreadPool* thread_pool) 35 SchedulerThreadPool* thread_pool)
36 : traits_(traits), thread_pool_(thread_pool) {} 36 : traits_(traits), thread_pool_(thread_pool) {}
37 37
38 // TaskRunner: 38 // TaskRunner:
39 bool PostDelayedTask(const tracked_objects::Location& from_here, 39 bool PostDelayedTask(const tracked_objects::Location& from_here,
40 const Closure& closure, 40 const Closure& closure,
41 TimeDelta delay) override { 41 TimeDelta delay) override {
42 // Post the task as part of a one-off single-task Sequence. 42 // Post the task as part of a one-off single-task Sequence.
43 return thread_pool_->PostTaskWithSequence( 43 return thread_pool_->PostTaskWithSequence(
44 WrapUnique( 44 WrapUnique(new Task(from_here, closure, traits_, delay)),
45 new Task(from_here, closure, traits_,
46 delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay)),
47 make_scoped_refptr(new Sequence)); 45 make_scoped_refptr(new Sequence));
48 } 46 }
49 47
50 bool RunsTasksOnCurrentThread() const override { 48 bool RunsTasksOnCurrentThread() const override {
51 return tls_current_thread_pool.Get().Get() == thread_pool_; 49 return tls_current_thread_pool.Get().Get() == thread_pool_;
52 } 50 }
53 51
54 private: 52 private:
55 ~SchedulerParallelTaskRunner() override = default; 53 ~SchedulerParallelTaskRunner() override = default;
56 54
(...skipping 12 matching lines...) Expand all
69 SchedulerSequencedTaskRunner(const TaskTraits& traits, 67 SchedulerSequencedTaskRunner(const TaskTraits& traits,
70 SchedulerThreadPool* thread_pool) 68 SchedulerThreadPool* thread_pool)
71 : traits_(traits), thread_pool_(thread_pool) {} 69 : traits_(traits), thread_pool_(thread_pool) {}
72 70
73 // SequencedTaskRunner: 71 // SequencedTaskRunner:
74 bool PostDelayedTask(const tracked_objects::Location& from_here, 72 bool PostDelayedTask(const tracked_objects::Location& from_here,
75 const Closure& closure, 73 const Closure& closure,
76 TimeDelta delay) override { 74 TimeDelta delay) override {
77 // Post the task as part of |sequence|. 75 // Post the task as part of |sequence|.
78 return thread_pool_->PostTaskWithSequence( 76 return thread_pool_->PostTaskWithSequence(
79 WrapUnique( 77 WrapUnique(new Task(from_here, closure, traits_, delay)), sequence_);
80 new Task(from_here, closure, traits_,
81 delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay)),
82 sequence_);
83 } 78 }
84 79
85 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 80 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
86 const Closure& closure, 81 const Closure& closure,
87 base::TimeDelta delay) override { 82 base::TimeDelta delay) override {
88 // Tasks are never nested within the task scheduler. 83 // Tasks are never nested within the task scheduler.
89 return PostDelayedTask(from_here, closure, delay); 84 return PostDelayedTask(from_here, closure, delay);
90 } 85 }
91 86
92 bool RunsTasksOnCurrentThread() const override { 87 bool RunsTasksOnCurrentThread() const override {
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_); 344 AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_);
350 idle_worker_threads_stack_.Push(worker_thread); 345 idle_worker_threads_stack_.Push(worker_thread);
351 DCHECK_LE(idle_worker_threads_stack_.Size(), worker_threads_.size()); 346 DCHECK_LE(idle_worker_threads_stack_.Size(), worker_threads_.size());
352 347
353 if (idle_worker_threads_stack_.Size() == worker_threads_.size()) 348 if (idle_worker_threads_stack_.Size() == worker_threads_.size())
354 idle_worker_threads_stack_cv_for_testing_->Broadcast(); 349 idle_worker_threads_stack_cv_for_testing_->Broadcast();
355 } 350 }
356 351
357 } // namespace internal 352 } // namespace internal
358 } // namespace base 353 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/priority_queue_unittest.cc ('k') | base/task_scheduler/scheduler_unique_stack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698