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

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

Issue 2708353003: Add support for priorities to TaskQueue. (Closed)
Patch Set: Address comments Created 3 years, 10 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/base/task_queue_gcd.cc » ('j') | no next file with comments »
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
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
166 enum class Priority {
167 NORMAL = 0,
168 HIGH,
169 LOW,
170 };
171
172 explicit TaskQueue(const char* queue_name,
173 Priority priority = Priority::NORMAL);
166 ~TaskQueue(); 174 ~TaskQueue();
167 175
168 static TaskQueue* Current(); 176 static TaskQueue* Current();
169 177
170 // Used for DCHECKing the current queue. 178 // Used for DCHECKing the current queue.
171 static bool IsCurrent(const char* queue_name); 179 static bool IsCurrent(const char* queue_name);
172 bool IsCurrent() const; 180 bool IsCurrent() const;
173 181
174 // TODO(tommi): For better debuggability, implement RTC_FROM_HERE. 182 // TODO(tommi): For better debuggability, implement RTC_FROM_HERE.
175 183
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 #elif defined(WEBRTC_WIN) 276 #elif defined(WEBRTC_WIN)
269 class MultimediaTimer; 277 class MultimediaTimer;
270 typedef std::unordered_map<UINT_PTR, std::unique_ptr<QueuedTask>> 278 typedef std::unordered_map<UINT_PTR, std::unique_ptr<QueuedTask>>
271 DelayedTasks; 279 DelayedTasks;
272 static void ThreadMain(void* context); 280 static void ThreadMain(void* context);
273 static bool ProcessQueuedMessages(DelayedTasks* delayed_tasks, 281 static bool ProcessQueuedMessages(DelayedTasks* delayed_tasks,
274 std::vector<MultimediaTimer>* timers); 282 std::vector<MultimediaTimer>* timers);
275 283
276 class WorkerThread : public PlatformThread { 284 class WorkerThread : public PlatformThread {
277 public: 285 public:
278 WorkerThread(ThreadRunFunction func, void* obj, const char* thread_name) 286 WorkerThread(ThreadRunFunction func,
279 : PlatformThread(func, obj, thread_name) {} 287 void* obj,
288 const char* thread_name,
289 ThreadPriority priority)
290 : PlatformThread(func, obj, thread_name, priority) {}
280 291
281 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) { 292 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) {
282 return PlatformThread::QueueAPC(apc_function, data); 293 return PlatformThread::QueueAPC(apc_function, data);
283 } 294 }
284 }; 295 };
285 WorkerThread thread_; 296 WorkerThread thread_;
286 #else 297 #else
287 #error not supported. 298 #error not supported.
288 #endif 299 #endif
289 300
290 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); 301 RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue);
291 }; 302 };
292 303
293 } // namespace rtc 304 } // namespace rtc
294 305
295 #endif // WEBRTC_BASE_TASK_QUEUE_H_ 306 #endif // WEBRTC_BASE_TASK_QUEUE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/task_queue_gcd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698