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

Side by Side Diff: base/task_scheduler/scheduler_worker_pool.h

Issue 2721553003: Remove SingleThreadTaskRunner Support from SchedulerWorkerPoolImpl (Closed)
Patch Set: Created 3 years, 9 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 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_ 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_
6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_ 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
fdoray 2017/03/14 18:35:47 No longer needed.
robliao 2017/03/14 22:58:28 Done.
14 #include "base/task_runner.h" 14 #include "base/task_runner.h"
15 #include "base/task_scheduler/sequence.h" 15 #include "base/task_scheduler/sequence.h"
16 #include "base/task_scheduler/task.h" 16 #include "base/task_scheduler/task.h"
17 #include "base/task_scheduler/task_traits.h" 17 #include "base/task_scheduler/task_traits.h"
18 18
19 namespace base { 19 namespace base {
20 namespace internal { 20 namespace internal {
21 21
22 class SchedulerWorker;
23 class SequenceSortKey; 22 class SequenceSortKey;
24 23
25 // Interface for a worker pool. 24 // Interface for a worker pool.
26 class BASE_EXPORT SchedulerWorkerPool { 25 class BASE_EXPORT SchedulerWorkerPool {
27 public: 26 public:
28 virtual ~SchedulerWorkerPool() = default; 27 virtual ~SchedulerWorkerPool() = default;
29 28
30 // Returns a TaskRunner whose PostTask invocations result in scheduling tasks 29 // Returns a TaskRunner whose PostTask invocations result in scheduling tasks
31 // in this SchedulerWorkerPool using |traits|. Tasks may run in any order and 30 // in this SchedulerWorkerPool using |traits|. Tasks may run in any order and
32 // in parallel. 31 // in parallel.
33 virtual scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( 32 virtual scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
34 const TaskTraits& traits) = 0; 33 const TaskTraits& traits) = 0;
35 34
36 // Returns a SequencedTaskRunner whose PostTask invocations result in 35 // Returns a SequencedTaskRunner whose PostTask invocations result in
37 // scheduling tasks in this SchedulerWorkerPool using |traits|. Tasks run one 36 // scheduling tasks in this SchedulerWorkerPool using |traits|. Tasks run one
38 // at a time in posting order. 37 // at a time in posting order.
39 virtual scoped_refptr<SequencedTaskRunner> 38 virtual scoped_refptr<SequencedTaskRunner>
40 CreateSequencedTaskRunnerWithTraits(const TaskTraits& traits) = 0; 39 CreateSequencedTaskRunnerWithTraits(const TaskTraits& traits) = 0;
41 40
42 // Returns a SingleThreadTaskRunner whose PostTask invocations result in
43 // scheduling tasks in this SchedulerWorkerPool using |traits|. Tasks run on a
44 // single thread in posting order.
45 virtual scoped_refptr<SingleThreadTaskRunner>
46 CreateSingleThreadTaskRunnerWithTraits(const TaskTraits& traits) = 0;
47
48 // Inserts |sequence| with |sequence_sort_key| into a queue of Sequences that 41 // Inserts |sequence| with |sequence_sort_key| into a queue of Sequences that
49 // can be processed by any worker owned by this SchedulerWorkerPool. Must only 42 // can be processed by any worker owned by this SchedulerWorkerPool. Must only
50 // be used to put |sequence| back into a queue after running a Task from it. 43 // be used to put |sequence| back into a queue after running a Task from it.
51 // The thread that calls this doesn't have to belong to this 44 // The thread that calls this doesn't have to belong to this
52 // SchedulerWorkerPool. 45 // SchedulerWorkerPool.
53 virtual void ReEnqueueSequence(scoped_refptr<Sequence> sequence, 46 virtual void ReEnqueueSequence(scoped_refptr<Sequence> sequence,
54 const SequenceSortKey& sequence_sort_key) = 0; 47 const SequenceSortKey& sequence_sort_key) = 0;
55 48
56 // Posts |task| to be executed by this SchedulerWorkerPool as part of 49 // Posts |task| to be executed by this SchedulerWorkerPool as part of
57 // |sequence|. If |worker| is non-null, |task| will be scheduled to run on it 50 // |sequence|. |task| won't be executed before its delayed run time, if any.
58 // specifically (note: |worker| must be owned by this SchedulerWorkerPool); 51 // Returns true if |task| is posted.
59 // otherwise, |task| will be added to the pending shared work. |task| won't be
60 // executed before its delayed run time, if any. Returns true if |task| is
61 // posted.
62 virtual bool PostTaskWithSequence(std::unique_ptr<Task> task, 52 virtual bool PostTaskWithSequence(std::unique_ptr<Task> task,
63 scoped_refptr<Sequence> sequence, 53 scoped_refptr<Sequence> sequence) = 0;
64 SchedulerWorker* worker) = 0;
65 54
66 // Posts |task| to be executed by this SchedulerWorkerPool as part of 55 // Posts |task| to be executed by this SchedulerWorkerPool as part of
67 // |sequence|. If |worker| is non-null, |task| will be scheduled to run on it 56 // |sequence|. This must only be called after |task| has gone through
68 // specifically (note: |worker| must be owned by this SchedulerWorkerPool); 57 // PostTaskWithSequence() and after |task|'s delayed run time.
69 // otherwise, |task| will be added to the pending shared work. This must only
70 // be called after |task| has gone through PostTaskWithSequence() and after
71 // |task|'s delayed run time.
72 virtual void PostTaskWithSequenceNow(std::unique_ptr<Task> task, 58 virtual void PostTaskWithSequenceNow(std::unique_ptr<Task> task,
73 scoped_refptr<Sequence> sequence, 59 scoped_refptr<Sequence> sequence) = 0;
74 SchedulerWorker* worker) = 0;
75 }; 60 };
76 61
77 } // namespace internal 62 } // namespace internal
78 } // namespace base 63 } // namespace base
79 64
80 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_ 65 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698