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_THREAD_H_ | 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ | 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 // Called when the main function of the SchedulerWorkerThread enters. | 40 // Called when the main function of the SchedulerWorkerThread enters. |
41 virtual void OnMainEntry() = 0; | 41 virtual void OnMainEntry() = 0; |
42 | 42 |
43 // Called when the main function of the SchedulerWorkerThread exits. | 43 // Called when the main function of the SchedulerWorkerThread exits. |
44 virtual void OnMainExit() = 0; | 44 virtual void OnMainExit() = 0; |
45 | 45 |
46 // Called by |worker_thread| to get a Sequence from which to run a Task. | 46 // Called by |worker_thread| to get a Sequence from which to run a Task. |
47 virtual scoped_refptr<Sequence> GetWork( | 47 virtual scoped_refptr<Sequence> GetWork( |
48 SchedulerWorkerThread* worker_thread) = 0; | 48 SchedulerWorkerThread* worker_thread) = 0; |
49 | 49 |
50 // Called after the SchedulerWorkerThread has tried to run a Task from | 50 // Called when |sequence| isn't empty after the SchedulerWorkerThread pops a |
51 // |sequence| (a TaskTracker might have prevented the Task from running). | 51 // Task from it. |sequence| is the last Sequence returned by GetWork(). |
52 // The Task is still in |sequence| when this is called. | 52 virtual void EnqueueSequence(scoped_refptr<Sequence> sequence) = 0; |
53 virtual void RanTaskFromSequence(scoped_refptr<Sequence> sequence) = 0; | |
54 }; | 53 }; |
55 | 54 |
56 // Creates a SchedulerWorkerThread with priority |thread_priority| that runs | 55 // Creates a SchedulerWorkerThread with priority |thread_priority| that runs |
57 // Tasks from Sequences returned by |delegate|. |task_tracker| is used to | 56 // Tasks from Sequences returned by |delegate|. |task_tracker| is used to |
58 // handle shutdown behavior of Tasks. Returns nullptr if creating the | 57 // handle shutdown behavior of Tasks. Returns nullptr if creating the |
59 // underlying platform thread fails. | 58 // underlying platform thread fails. |
60 static std::unique_ptr<SchedulerWorkerThread> CreateSchedulerWorkerThread( | 59 static std::unique_ptr<SchedulerWorkerThread> CreateSchedulerWorkerThread( |
61 ThreadPriority thread_priority, | 60 ThreadPriority thread_priority, |
62 Delegate* delegate, | 61 Delegate* delegate, |
63 TaskTracker* task_tracker); | 62 TaskTracker* task_tracker); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // True once JoinForTesting() has been called. | 100 // True once JoinForTesting() has been called. |
102 bool should_exit_for_testing_ = false; | 101 bool should_exit_for_testing_ = false; |
103 | 102 |
104 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerThread); | 103 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerThread); |
105 }; | 104 }; |
106 | 105 |
107 } // namespace internal | 106 } // namespace internal |
108 } // namespace base | 107 } // namespace base |
109 | 108 |
110 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ | 109 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_THREAD_H_ |
OLD | NEW |