OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 // | 154 // |
155 // A note on destruction: | 155 // A note on destruction: |
156 // | 156 // |
157 // When a TaskQueue is deleted, pending tasks will not be executed but they will | 157 // When a TaskQueue is deleted, pending tasks will not be executed but they will |
158 // be deleted. The deletion of tasks may happen asynchronously after the | 158 // be deleted. The deletion of tasks may happen asynchronously after the |
159 // TaskQueue itself has been deleted or it may happen synchronously while the | 159 // TaskQueue itself has been deleted or it may happen synchronously while the |
160 // TaskQueue instance is being deleted. This may vary from one OS to the next | 160 // TaskQueue instance is being deleted. This may vary from one OS to the next |
161 // so assumptions about lifetimes of pending tasks should not be made. | 161 // so assumptions about lifetimes of pending tasks should not be made. |
162 class LOCKABLE TaskQueue { | 162 class LOCKABLE TaskQueue { |
163 public: | 163 public: |
164 explicit TaskQueue(const char* queue_name); | 164 // TaskQueue priority levels. On some platforms these will map to thread |
165 // TODO(tommi): Implement move semantics? | 165 // priorities, on others such as Mac and iOS, GCD queue priorities. |
the sun
2017/02/24 09:03:43
Did you mean to remove comment? (FYI: Move semanti
tommi
2017/02/24 17:34:41
Yeah that's why I removed it. If we find we need i
| |
166 enum Priority { | |
the sun
2017/02/24 09:03:43
We can use enum class these days
tommi
2017/02/24 17:34:41
oooh! completely forgot - Done!
| |
167 NORMAL = 0, | |
168 HIGH, | |
169 LOW, | |
170 }; | |
171 | |
172 explicit TaskQueue(const char* queue_name, Priority priority = NORMAL); | |
166 ~TaskQueue(); | 173 ~TaskQueue(); |
167 | 174 |
168 static TaskQueue* Current(); | 175 static TaskQueue* Current(); |
169 | 176 |
170 // Used for DCHECKing the current queue. | 177 // Used for DCHECKing the current queue. |
171 static bool IsCurrent(const char* queue_name); | 178 static bool IsCurrent(const char* queue_name); |
172 bool IsCurrent() const; | 179 bool IsCurrent() const; |
173 | 180 |
174 // TODO(tommi): For better debuggability, implement RTC_FROM_HERE. | 181 // TODO(tommi): For better debuggability, implement RTC_FROM_HERE. |
175 | 182 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 #elif defined(WEBRTC_WIN) | 275 #elif defined(WEBRTC_WIN) |
269 class MultimediaTimer; | 276 class MultimediaTimer; |
270 typedef std::unordered_map<UINT_PTR, std::unique_ptr<QueuedTask>> | 277 typedef std::unordered_map<UINT_PTR, std::unique_ptr<QueuedTask>> |
271 DelayedTasks; | 278 DelayedTasks; |
272 static void ThreadMain(void* context); | 279 static void ThreadMain(void* context); |
273 static bool ProcessQueuedMessages(DelayedTasks* delayed_tasks, | 280 static bool ProcessQueuedMessages(DelayedTasks* delayed_tasks, |
274 std::vector<MultimediaTimer>* timers); | 281 std::vector<MultimediaTimer>* timers); |
275 | 282 |
276 class WorkerThread : public PlatformThread { | 283 class WorkerThread : public PlatformThread { |
277 public: | 284 public: |
278 WorkerThread(ThreadRunFunction func, void* obj, const char* thread_name) | 285 WorkerThread(ThreadRunFunction func, |
279 : PlatformThread(func, obj, thread_name) {} | 286 void* obj, |
287 const char* thread_name, | |
288 ThreadPriority priority) | |
289 : PlatformThread(func, obj, thread_name, priority) {} | |
280 | 290 |
281 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) { | 291 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) { |
282 return PlatformThread::QueueAPC(apc_function, data); | 292 return PlatformThread::QueueAPC(apc_function, data); |
283 } | 293 } |
284 }; | 294 }; |
285 WorkerThread thread_; | 295 WorkerThread thread_; |
286 #else | 296 #else |
287 #error not supported. | 297 #error not supported. |
288 #endif | 298 #endif |
289 | 299 |
290 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); | 300 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); |
291 }; | 301 }; |
292 | 302 |
293 } // namespace rtc | 303 } // namespace rtc |
294 | 304 |
295 #endif // WEBRTC_BASE_TASK_QUEUE_H_ | 305 #endif // WEBRTC_BASE_TASK_QUEUE_H_ |
OLD | NEW |