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

Side by Side Diff: webrtc/base/task_queue_win.cc

Issue 2701283002: Add support for priorities in TaskQueue (Closed)
Patch Set: Rebase 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 | « webrtc/base/task_queue_libevent.cc ('k') | no next file » | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 void* thread_context; 42 void* thread_context;
43 }; 43 };
44 44
45 void CALLBACK InitializeQueueThread(ULONG_PTR param) { 45 void CALLBACK InitializeQueueThread(ULONG_PTR param) {
46 MSG msg; 46 MSG msg;
47 ::PeekMessage(&msg, nullptr, WM_USER, WM_USER, PM_NOREMOVE); 47 ::PeekMessage(&msg, nullptr, WM_USER, WM_USER, PM_NOREMOVE);
48 ThreadStartupData* data = reinterpret_cast<ThreadStartupData*>(param); 48 ThreadStartupData* data = reinterpret_cast<ThreadStartupData*>(param);
49 ::TlsSetValue(GetQueuePtrTls(), data->thread_context); 49 ::TlsSetValue(GetQueuePtrTls(), data->thread_context);
50 data->started->Set(); 50 data->started->Set();
51 } 51 }
52
53 ThreadPriority TaskQueuePriorityToThreadPriority(TaskQueue::Priority priority) {
54 switch (priority) {
55 case TaskQueue::HIGH:
56 return kRealtimePriority;
57 case TaskQueue::LOW:
58 return kLowPriority;
59 case TaskQueue::NORMAL:
60 default:
61 break;
62 }
63 return kNormalPriority;
64 }
52 } // namespace 65 } // namespace
53 66
54 class TaskQueue::MultimediaTimer { 67 class TaskQueue::MultimediaTimer {
55 public: 68 public:
56 // kMaxTimers defines the limit of how many MultimediaTimer instances should 69 // kMaxTimers defines the limit of how many MultimediaTimer instances should
57 // be created. 70 // be created.
58 // Background: The maximum number of supported handles for Wait functions, is 71 // Background: The maximum number of supported handles for Wait functions, is
59 // MAXIMUM_WAIT_OBJECTS - 1 (63). 72 // MAXIMUM_WAIT_OBJECTS - 1 (63).
60 // There are some ways to work around the limitation but as it turns out, the 73 // There are some ways to work around the limitation but as it turns out, the
61 // limit of concurrently active multimedia timers per process, is much lower, 74 // limit of concurrently active multimedia timers per process, is much lower,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 151 }
139 } 152 }
140 153
141 HANDLE event_ = nullptr; 154 HANDLE event_ = nullptr;
142 MMRESULT timer_id_ = 0; 155 MMRESULT timer_id_ = 0;
143 std::unique_ptr<QueuedTask> task_; 156 std::unique_ptr<QueuedTask> task_;
144 157
145 RTC_DISALLOW_COPY_AND_ASSIGN(MultimediaTimer); 158 RTC_DISALLOW_COPY_AND_ASSIGN(MultimediaTimer);
146 }; 159 };
147 160
148 TaskQueue::TaskQueue(const char* queue_name) 161 TaskQueue::TaskQueue(const char* queue_name, Priority priority /*= NORMAL*/)
149 : thread_(&TaskQueue::ThreadMain, this, queue_name) { 162 : thread_(&TaskQueue::ThreadMain,
163 this,
164 queue_name,
165 TaskQueuePriorityToThreadPriority(priority)) {
150 RTC_DCHECK(queue_name); 166 RTC_DCHECK(queue_name);
151 thread_.Start(); 167 thread_.Start();
152 Event event(false, false); 168 Event event(false, false);
153 ThreadStartupData startup = {&event, this}; 169 ThreadStartupData startup = {&event, this};
154 RTC_CHECK(thread_.QueueAPC(&InitializeQueueThread, 170 RTC_CHECK(thread_.QueueAPC(&InitializeQueueThread,
155 reinterpret_cast<ULONG_PTR>(&startup))); 171 reinterpret_cast<ULONG_PTR>(&startup)));
156 event.Wait(Event::kForever); 172 event.Wait(Event::kForever);
157 } 173 }
158 174
159 TaskQueue::~TaskQueue() { 175 TaskQueue::~TaskQueue() {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 371 }
356 } else { 372 } else {
357 ::TranslateMessage(&msg); 373 ::TranslateMessage(&msg);
358 ::DispatchMessage(&msg); 374 ::DispatchMessage(&msg);
359 } 375 }
360 } 376 }
361 return msg.message != WM_QUIT; 377 return msg.message != WM_QUIT;
362 } 378 }
363 379
364 } // namespace rtc 380 } // namespace rtc
OLDNEW
« 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