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 |
11 #ifndef WEBRTC_BASE_TASK_QUEUE_H_ | 11 #ifndef WEBRTC_BASE_TASK_QUEUE_H_ |
12 #define WEBRTC_BASE_TASK_QUEUE_H_ | 12 #define WEBRTC_BASE_TASK_QUEUE_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <memory> | 15 #include <memory> |
| 16 #include <unordered_map> |
16 | 17 |
17 #if defined(WEBRTC_MAC) && !defined(WEBRTC_BUILD_LIBEVENT) | 18 #if defined(WEBRTC_MAC) && !defined(WEBRTC_BUILD_LIBEVENT) |
18 #include <dispatch/dispatch.h> | 19 #include <dispatch/dispatch.h> |
19 #endif | 20 #endif |
20 | 21 |
21 #include "webrtc/base/constructormagic.h" | 22 #include "webrtc/base/constructormagic.h" |
22 #include "webrtc/base/criticalsection.h" | 23 #include "webrtc/base/criticalsection.h" |
23 | 24 |
24 #if defined(WEBRTC_WIN) || defined(WEBRTC_BUILD_LIBEVENT) | 25 #if defined(WEBRTC_WIN) || defined(WEBRTC_BUILD_LIBEVENT) |
25 #include "webrtc/base/platform_thread.h" | 26 #include "webrtc/base/platform_thread.h" |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 rtc::CriticalSection pending_lock_; | 247 rtc::CriticalSection pending_lock_; |
247 std::list<std::unique_ptr<QueuedTask>> pending_ GUARDED_BY(pending_lock_); | 248 std::list<std::unique_ptr<QueuedTask>> pending_ GUARDED_BY(pending_lock_); |
248 std::list<PostAndReplyTask*> pending_replies_ GUARDED_BY(pending_lock_); | 249 std::list<PostAndReplyTask*> pending_replies_ GUARDED_BY(pending_lock_); |
249 #elif defined(WEBRTC_MAC) | 250 #elif defined(WEBRTC_MAC) |
250 struct QueueContext; | 251 struct QueueContext; |
251 struct TaskContext; | 252 struct TaskContext; |
252 struct PostTaskAndReplyContext; | 253 struct PostTaskAndReplyContext; |
253 dispatch_queue_t queue_; | 254 dispatch_queue_t queue_; |
254 QueueContext* const context_; | 255 QueueContext* const context_; |
255 #elif defined(WEBRTC_WIN) | 256 #elif defined(WEBRTC_WIN) |
| 257 typedef std::unordered_map<UINT_PTR, std::unique_ptr<QueuedTask>> |
| 258 DelayedTasks; |
256 static bool ThreadMain(void* context); | 259 static bool ThreadMain(void* context); |
| 260 static bool ProcessQueuedMessages(DelayedTasks* delayed_tasks); |
257 | 261 |
258 class WorkerThread : public PlatformThread { | 262 class WorkerThread : public PlatformThread { |
259 public: | 263 public: |
260 WorkerThread(ThreadRunFunction func, void* obj, const char* thread_name) | 264 WorkerThread(ThreadRunFunction func, void* obj, const char* thread_name) |
261 : PlatformThread(func, obj, thread_name) {} | 265 : PlatformThread(func, obj, thread_name) {} |
262 | 266 |
263 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) { | 267 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) { |
264 return PlatformThread::QueueAPC(apc_function, data); | 268 return PlatformThread::QueueAPC(apc_function, data); |
265 } | 269 } |
266 }; | 270 }; |
267 WorkerThread thread_; | 271 WorkerThread thread_; |
268 #else | 272 #else |
269 #error not supported. | 273 #error not supported. |
270 #endif | 274 #endif |
271 | 275 |
272 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); | 276 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); |
273 }; | 277 }; |
274 | 278 |
275 } // namespace rtc | 279 } // namespace rtc |
276 | 280 |
277 #endif // WEBRTC_BASE_TASK_QUEUE_H_ | 281 #endif // WEBRTC_BASE_TASK_QUEUE_H_ |
OLD | NEW |