| 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 <queue> |
| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 std::list<scoped_refptr<ReplyTaskOwnerRef>> pending_replies_ | 268 std::list<scoped_refptr<ReplyTaskOwnerRef>> pending_replies_ |
| 268 GUARDED_BY(pending_lock_); | 269 GUARDED_BY(pending_lock_); |
| 269 #elif defined(WEBRTC_MAC) | 270 #elif defined(WEBRTC_MAC) |
| 270 struct QueueContext; | 271 struct QueueContext; |
| 271 struct TaskContext; | 272 struct TaskContext; |
| 272 struct PostTaskAndReplyContext; | 273 struct PostTaskAndReplyContext; |
| 273 dispatch_queue_t queue_; | 274 dispatch_queue_t queue_; |
| 274 QueueContext* const context_; | 275 QueueContext* const context_; |
| 275 #elif defined(WEBRTC_WIN) | 276 #elif defined(WEBRTC_WIN) |
| 276 class ThreadState; | 277 class ThreadState; |
| 278 void RunPendingTasks(); |
| 277 static void ThreadMain(void* context); | 279 static void ThreadMain(void* context); |
| 278 | 280 |
| 279 class WorkerThread : public PlatformThread { | 281 class WorkerThread : public PlatformThread { |
| 280 public: | 282 public: |
| 281 WorkerThread(ThreadRunFunction func, | 283 WorkerThread(ThreadRunFunction func, |
| 282 void* obj, | 284 void* obj, |
| 283 const char* thread_name, | 285 const char* thread_name, |
| 284 ThreadPriority priority) | 286 ThreadPriority priority) |
| 285 : PlatformThread(func, obj, thread_name, priority) {} | 287 : PlatformThread(func, obj, thread_name, priority) {} |
| 286 | 288 |
| 287 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) { | 289 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) { |
| 288 return PlatformThread::QueueAPC(apc_function, data); | 290 return PlatformThread::QueueAPC(apc_function, data); |
| 289 } | 291 } |
| 290 }; | 292 }; |
| 291 WorkerThread thread_; | 293 WorkerThread thread_; |
| 294 rtc::CriticalSection pending_lock_; |
| 295 std::queue<std::unique_ptr<QueuedTask>> pending_ GUARDED_BY(pending_lock_); |
| 296 HANDLE in_queue_; |
| 292 #else | 297 #else |
| 293 #error not supported. | 298 #error not supported. |
| 294 #endif | 299 #endif |
| 295 | 300 |
| 296 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); | 301 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); |
| 297 }; | 302 }; |
| 298 | 303 |
| 299 } // namespace rtc | 304 } // namespace rtc |
| 300 | 305 |
| 301 #endif // WEBRTC_BASE_TASK_QUEUE_H_ | 306 #endif // WEBRTC_BASE_TASK_QUEUE_H_ |
| OLD | NEW |