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

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

Issue 2076153002: [TaskScheduler] Support TaskRunnerHandles from parallel tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mix_c_Ab
Patch Set: Created 4 years, 6 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
« no previous file with comments | « base/task_scheduler/scheduler_thread_pool.h ('k') | base/task_scheduler/task.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // long as |thread_pool| is alive. 42 // long as |thread_pool| is alive.
43 // TODO(robliao): Find a concrete way to manage |thread_pool|'s memory. 43 // TODO(robliao): Find a concrete way to manage |thread_pool|'s memory.
44 SchedulerParallelTaskRunner(const TaskTraits& traits, 44 SchedulerParallelTaskRunner(const TaskTraits& traits,
45 SchedulerThreadPool* thread_pool) 45 SchedulerThreadPool* thread_pool)
46 : traits_(traits), thread_pool_(thread_pool) {} 46 : traits_(traits), thread_pool_(thread_pool) {}
47 47
48 // TaskRunner: 48 // TaskRunner:
49 bool PostDelayedTask(const tracked_objects::Location& from_here, 49 bool PostDelayedTask(const tracked_objects::Location& from_here,
50 const Closure& closure, 50 const Closure& closure,
51 TimeDelta delay) override { 51 TimeDelta delay) override {
52 std::unique_ptr<Task> task(new Task(from_here, closure, traits_, delay));
53 task->task_runner_ref = this;
54
52 // Post the task as part of a one-off single-task Sequence. 55 // Post the task as part of a one-off single-task Sequence.
53 return thread_pool_->PostTaskWithSequence( 56 return thread_pool_->PostTaskWithSequence(
54 WrapUnique(new Task(from_here, closure, traits_, delay)), 57 std::move(task), make_scoped_refptr(new Sequence), nullptr);
55 make_scoped_refptr(new Sequence), nullptr);
56 } 58 }
57 59
58 bool RunsTasksOnCurrentThread() const override { 60 bool RunsTasksOnCurrentThread() const override {
59 return tls_current_thread_pool.Get().Get() == thread_pool_; 61 return tls_current_thread_pool.Get().Get() == thread_pool_;
60 } 62 }
61 63
62 private: 64 private:
63 ~SchedulerParallelTaskRunner() override = default; 65 ~SchedulerParallelTaskRunner() override = default;
64 66
65 const TaskTraits traits_; 67 const TaskTraits traits_;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 563 }
562 564
563 void SchedulerThreadPoolImpl::RemoveFromIdleWorkerThreadsStack( 565 void SchedulerThreadPoolImpl::RemoveFromIdleWorkerThreadsStack(
564 SchedulerWorkerThread* worker_thread) { 566 SchedulerWorkerThread* worker_thread) {
565 AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_); 567 AutoSchedulerLock auto_lock(idle_worker_threads_stack_lock_);
566 idle_worker_threads_stack_.Remove(worker_thread); 568 idle_worker_threads_stack_.Remove(worker_thread);
567 } 569 }
568 570
569 } // namespace internal 571 } // namespace internal
570 } // namespace base 572 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_thread_pool.h ('k') | base/task_scheduler/task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698