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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // returned. | 109 // returned. |
110 ~SchedulerWorker(); | 110 ~SchedulerWorker(); |
111 | 111 |
112 // Wakes up this SchedulerWorker if it wasn't already awake. After this | 112 // Wakes up this SchedulerWorker if it wasn't already awake. After this |
113 // is called, this SchedulerWorker will run Tasks from Sequences | 113 // is called, this SchedulerWorker will run Tasks from Sequences |
114 // returned by the GetWork() method of its delegate until it returns nullptr. | 114 // returned by the GetWork() method of its delegate until it returns nullptr. |
115 // WakeUp() may fail if the worker is detached and it fails to allocate a new | 115 // WakeUp() may fail if the worker is detached and it fails to allocate a new |
116 // worker. If this happens, there will be no call to GetWork(). | 116 // worker. If this happens, there will be no call to GetWork(). |
117 void WakeUp(); | 117 void WakeUp(); |
118 | 118 |
| 119 // Requests destruction of |worker| upon detachment. After this call returns, |
| 120 // do not reference |worker| or anything provided by it. |
| 121 static void DestroyAfterDetachment(std::unique_ptr<SchedulerWorker> worker); |
| 122 |
119 SchedulerWorker::Delegate* delegate() { return delegate_.get(); } | 123 SchedulerWorker::Delegate* delegate() { return delegate_.get(); } |
120 | 124 |
121 // Joins this SchedulerWorker. If a Task is already running, it will be | 125 // Joins this SchedulerWorker. If a Task is already running, it will be |
122 // allowed to complete its execution. This can only be called once. | 126 // allowed to complete its execution. This can only be called once. |
123 // | 127 // |
124 // Note: A thread that detaches before JoinForTesting() is called may still be | 128 // Note: A thread that detaches before JoinForTesting() is called may still be |
125 // running after JoinForTesting() returns. However, it can't run tasks after | 129 // running after JoinForTesting() returns. However, it can't run tasks after |
126 // JoinForTesting() returns. | 130 // JoinForTesting() returns. |
127 void JoinForTesting(); | 131 void JoinForTesting(); |
128 | 132 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // Set once JoinForTesting() has been called. | 168 // Set once JoinForTesting() has been called. |
165 AtomicFlag should_exit_for_testing_; | 169 AtomicFlag should_exit_for_testing_; |
166 | 170 |
167 DISALLOW_COPY_AND_ASSIGN(SchedulerWorker); | 171 DISALLOW_COPY_AND_ASSIGN(SchedulerWorker); |
168 }; | 172 }; |
169 | 173 |
170 } // namespace internal | 174 } // namespace internal |
171 } // namespace base | 175 } // namespace base |
172 | 176 |
173 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ | 177 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_H_ |
OLD | NEW |