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

Unified Diff: webrtc/base/task_queue_win.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/task_queue_libevent.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/task_queue_win.cc
diff --git a/webrtc/base/task_queue_win.cc b/webrtc/base/task_queue_win.cc
index c8ef7211e895f8cffc47db8619ee1f35114349c2..5850b2947ed2822f1d646efbff6a00af91343854 100644
--- a/webrtc/base/task_queue_win.cc
+++ b/webrtc/base/task_queue_win.cc
@@ -24,6 +24,8 @@ namespace {
#define WM_RUN_TASK WM_USER + 1
#define WM_QUEUE_DELAYED_TASK WM_USER + 2
+using Priority = TaskQueue::Priority;
+
DWORD g_queue_ptr_tls = 0;
BOOL CALLBACK InitializeTls(PINIT_ONCE init_once, void* param, void** context) {
@@ -49,6 +51,21 @@ void CALLBACK InitializeQueueThread(ULONG_PTR param) {
::TlsSetValue(GetQueuePtrTls(), data->thread_context);
data->started->Set();
}
+
+ThreadPriority TaskQueuePriorityToThreadPriority(Priority priority) {
+ switch (priority) {
+ case Priority::HIGH:
+ return kRealtimePriority;
+ case Priority::LOW:
+ return kLowPriority;
+ case Priority::NORMAL:
+ return kNormalPriority;
+ default:
+ RTC_NOTREACHED();
+ break;
+ }
+ return kNormalPriority;
+}
} // namespace
class TaskQueue::MultimediaTimer {
@@ -145,8 +162,11 @@ class TaskQueue::MultimediaTimer {
RTC_DISALLOW_COPY_AND_ASSIGN(MultimediaTimer);
};
-TaskQueue::TaskQueue(const char* queue_name)
- : thread_(&TaskQueue::ThreadMain, this, queue_name) {
+TaskQueue::TaskQueue(const char* queue_name, Priority priority /*= NORMAL*/)
+ : thread_(&TaskQueue::ThreadMain,
+ this,
+ queue_name,
+ TaskQueuePriorityToThreadPriority(priority)) {
RTC_DCHECK(queue_name);
thread_.Start();
Event event(false, false);
« no previous file with comments | « webrtc/base/task_queue_libevent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698