Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: webrtc/rtc_base/task_queue.h

Issue 3009133002: Convert windows TaskQueue implementation to pimpl convention. (Closed)
Patch Set: Fix ThreadMain, and add PostTask template. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/rtc_base/task_queue_win.cc » ('j') | webrtc/rtc_base/task_queue_win.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_RTC_BASE_TASK_QUEUE_H_ 11 #ifndef WEBRTC_RTC_BASE_TASK_QUEUE_H_
12 #define WEBRTC_RTC_BASE_TASK_QUEUE_H_ 12 #define WEBRTC_RTC_BASE_TASK_QUEUE_H_
13 13
14 #include <list> 14 #include <list>
15 #include <memory> 15 #include <memory>
16 #include <queue> 16 #include <queue>
17 #include <type_traits> 17 #include <type_traits>
18 18
19 #if defined(WEBRTC_MAC) 19 #if defined(WEBRTC_MAC)
20 #include <dispatch/dispatch.h> 20 #include <dispatch/dispatch.h>
21 #endif 21 #endif
22 22
23 #include "webrtc/rtc_base/constructormagic.h" 23 #include "webrtc/rtc_base/constructormagic.h"
24 #include "webrtc/rtc_base/criticalsection.h" 24 #include "webrtc/rtc_base/criticalsection.h"
25 #include "webrtc/rtc_base/scoped_ref_ptr.h" 25 #include "webrtc/rtc_base/scoped_ref_ptr.h"
26 26
27 #if defined(WEBRTC_WIN)
28 #include "webrtc/rtc_base/platform_thread.h"
29 #endif
30
31 namespace rtc { 27 namespace rtc {
32 28
33 // Base interface for asynchronously executed tasks. 29 // Base interface for asynchronously executed tasks.
34 // The interface basically consists of a single function, Run(), that executes 30 // The interface basically consists of a single function, Run(), that executes
35 // on the target queue. For more details see the Run() method and TaskQueue. 31 // on the target queue. For more details see the Run() method and TaskQueue.
36 class QueuedTask { 32 class QueuedTask {
37 public: 33 public:
38 QueuedTask() {} 34 QueuedTask() {}
39 virtual ~QueuedTask() {} 35 virtual ~QueuedTask() {}
40 36
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 std::unique_ptr<QueuedTask>(new ClosureTask<Closure2>(reply))); 235 std::unique_ptr<QueuedTask>(new ClosureTask<Closure2>(reply)));
240 } 236 }
241 237
242 private: 238 private:
243 #if defined(WEBRTC_MAC) 239 #if defined(WEBRTC_MAC)
244 struct QueueContext; 240 struct QueueContext;
245 struct TaskContext; 241 struct TaskContext;
246 struct PostTaskAndReplyContext; 242 struct PostTaskAndReplyContext;
247 dispatch_queue_t queue_; 243 dispatch_queue_t queue_;
248 QueueContext* const context_; 244 QueueContext* const context_;
249 #elif defined(WEBRTC_WIN)
250 class ThreadState;
251 void RunPendingTasks();
252 static void ThreadMain(void* context);
253
254 class WorkerThread : public PlatformThread {
255 public:
256 WorkerThread(ThreadRunFunction func,
257 void* obj,
258 const char* thread_name,
259 ThreadPriority priority)
260 : PlatformThread(func, obj, thread_name, priority) {}
261
262 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) {
263 return PlatformThread::QueueAPC(apc_function, data);
264 }
265 };
266 WorkerThread thread_;
267 rtc::CriticalSection pending_lock_;
268 std::queue<std::unique_ptr<QueuedTask>> pending_ GUARDED_BY(pending_lock_);
269 HANDLE in_queue_;
270 #else 245 #else
271 class Impl; 246 class Impl;
272 const scoped_refptr<Impl> impl_; 247 const scoped_refptr<Impl> impl_;
273 #endif 248 #endif
274 249
275 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); 250 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue);
276 }; 251 };
277 252
278 } // namespace rtc 253 } // namespace rtc
279 254
280 #endif // WEBRTC_RTC_BASE_TASK_QUEUE_H_ 255 #endif // WEBRTC_RTC_BASE_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/rtc_base/task_queue_win.cc » ('j') | webrtc/rtc_base/task_queue_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698