OLD | NEW |
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_H_ | 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ |
6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ | 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // Called by a thread managed by |worker| when it enters its main function. | 46 // Called by a thread managed by |worker| when it enters its main function. |
47 // If a thread is recreated after detachment, |detach_duration| is the time | 47 // If a thread is recreated after detachment, |detach_duration| is the time |
48 // elapsed since detachment. Otherwise, if this is the first thread created | 48 // elapsed since detachment. Otherwise, if this is the first thread created |
49 // for |worker|, |detach_duration| is TimeDelta::Max(). | 49 // for |worker|, |detach_duration| is TimeDelta::Max(). |
50 virtual void OnMainEntry(SchedulerWorker* worker) = 0; | 50 virtual void OnMainEntry(SchedulerWorker* worker) = 0; |
51 | 51 |
52 // Called by a thread managed by |worker| to get a Sequence from which to | 52 // Called by a thread managed by |worker| to get a Sequence from which to |
53 // run a Task. | 53 // run a Task. |
54 virtual scoped_refptr<Sequence> GetWork(SchedulerWorker* worker) = 0; | 54 virtual scoped_refptr<Sequence> GetWork(SchedulerWorker* worker) = 0; |
55 | 55 |
56 // Called by the SchedulerWorker after it ran a task with |task_priority|. | 56 // Called by the SchedulerWorker after it ran a task. |
57 // |task_latency| is the time elapsed between when the task was posted and | 57 virtual void DidRunTask() = 0; |
58 // when it started to run. | |
59 virtual void DidRunTaskWithPriority(TaskPriority task_priority, | |
60 const TimeDelta& task_latency) = 0; | |
61 | 58 |
62 // Called when |sequence| isn't empty after the SchedulerWorker pops a Task | 59 // Called when |sequence| isn't empty after the SchedulerWorker pops a Task |
63 // from it. |sequence| is the last Sequence returned by GetWork(). | 60 // from it. |sequence| is the last Sequence returned by GetWork(). |
64 virtual void ReEnqueueSequence(scoped_refptr<Sequence> sequence) = 0; | 61 virtual void ReEnqueueSequence(scoped_refptr<Sequence> sequence) = 0; |
65 | 62 |
66 // Called by a thread to determine how long to sleep before the next call to | 63 // Called by a thread to determine how long to sleep before the next call to |
67 // GetWork(). GetWork() may be called before this timeout expires if the | 64 // GetWork(). GetWork() may be called before this timeout expires if the |
68 // worker's WakeUp() method is called. | 65 // worker's WakeUp() method is called. |
69 virtual TimeDelta GetSleepTimeout() = 0; | 66 virtual TimeDelta GetSleepTimeout() = 0; |
70 | 67 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Set once JoinForTesting() has been called. | 151 // Set once JoinForTesting() has been called. |
155 AtomicFlag should_exit_for_testing_; | 152 AtomicFlag should_exit_for_testing_; |
156 | 153 |
157 DISALLOW_COPY_AND_ASSIGN(SchedulerWorker); | 154 DISALLOW_COPY_AND_ASSIGN(SchedulerWorker); |
158 }; | 155 }; |
159 | 156 |
160 } // namespace internal | 157 } // namespace internal |
161 } // namespace base | 158 } // namespace base |
162 | 159 |
163 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ | 160 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ |
OLD | NEW |