blob: 5eb3776ceab9acae158247d2ed082332bddee54b [file] [log] [blame]
tommic06b1332016-05-14 11:31:40 -07001/*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Danil Chapovalov826f2e72019-02-20 18:13:09 +010011#include "rtc_base/task_queue_win.h"
tommic06b1332016-05-14 11:31:40 -070012
Yves Gerey665174f2018-06-19 15:03:05 +020013// clang-format off
14// clang formating would change include order.
15
Danil Chapovalov02fddf62018-02-12 12:41:16 +010016// Include winsock2.h before including <windows.h> to maintain consistency with
Niels Möllerb06b0a62018-05-25 10:05:34 +020017// win32.h. To include win32.h directly, it must be broken out into its own
18// build target.
Danil Chapovalov02fddf62018-02-12 12:41:16 +010019#include <winsock2.h>
20#include <windows.h>
Yves Gerey665174f2018-06-19 15:03:05 +020021#include <sal.h> // Must come after windows headers.
Danil Chapovalov02fddf62018-02-12 12:41:16 +010022#include <mmsystem.h> // Must come after windows headers.
Yves Gerey665174f2018-06-19 15:03:05 +020023// clang-format on
tommic06b1332016-05-14 11:31:40 -070024#include <string.h>
tommic06b1332016-05-14 11:31:40 -070025
tommif9d91542017-02-17 02:47:11 -080026#include <algorithm>
Mirko Bonadei317a1f02019-09-17 17:06:18 +020027#include <memory>
tommi0b942152017-03-10 09:33:53 -080028#include <queue>
Danil Chapovalov6f09ae22017-10-12 14:39:25 +020029#include <utility>
tommif9d91542017-02-17 02:47:11 -080030
Danil Chapovalov826f2e72019-02-20 18:13:09 +010031#include "absl/strings/string_view.h"
32#include "api/task_queue/queued_task.h"
33#include "api/task_queue/task_queue_base.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020034#include "rtc_base/arraysize.h"
35#include "rtc_base/checks.h"
36#include "rtc_base/event.h"
37#include "rtc_base/logging.h"
Karl Wiberge40468b2017-11-22 10:42:26 +010038#include "rtc_base/numerics/safe_conversions.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020039#include "rtc_base/platform_thread.h"
Steve Anton10542f22019-01-11 09:11:00 -080040#include "rtc_base/time_utils.h"
Markus Handell18523c32020-07-08 17:55:58 +020041#include "rtc_base/synchronization/mutex.h"
tommic06b1332016-05-14 11:31:40 -070042
Danil Chapovalov826f2e72019-02-20 18:13:09 +010043namespace webrtc {
tommic06b1332016-05-14 11:31:40 -070044namespace {
45#define WM_RUN_TASK WM_USER + 1
46#define WM_QUEUE_DELAYED_TASK WM_USER + 2
47
tommic06b1332016-05-14 11:31:40 -070048void CALLBACK InitializeQueueThread(ULONG_PTR param) {
49 MSG msg;
tommif9d91542017-02-17 02:47:11 -080050 ::PeekMessage(&msg, nullptr, WM_USER, WM_USER, PM_NOREMOVE);
Danil Chapovalov826f2e72019-02-20 18:13:09 +010051 rtc::Event* data = reinterpret_cast<rtc::Event*>(param);
52 data->Set();
tommic06b1332016-05-14 11:31:40 -070053}
tommic9bb7912017-02-24 10:42:14 -080054
Danil Chapovalov826f2e72019-02-20 18:13:09 +010055rtc::ThreadPriority TaskQueuePriorityToThreadPriority(
56 TaskQueueFactory::Priority priority) {
tommic9bb7912017-02-24 10:42:14 -080057 switch (priority) {
Danil Chapovalov826f2e72019-02-20 18:13:09 +010058 case TaskQueueFactory::Priority::HIGH:
59 return rtc::kRealtimePriority;
60 case TaskQueueFactory::Priority::LOW:
61 return rtc::kLowPriority;
62 case TaskQueueFactory::Priority::NORMAL:
63 return rtc::kNormalPriority;
tommic9bb7912017-02-24 10:42:14 -080064 default:
65 RTC_NOTREACHED();
66 break;
67 }
Danil Chapovalov826f2e72019-02-20 18:13:09 +010068 return rtc::kNormalPriority;
tommic9bb7912017-02-24 10:42:14 -080069}
tommi5bdee472017-03-03 05:20:12 -080070
tommi0b942152017-03-10 09:33:53 -080071int64_t GetTick() {
tommi5bdee472017-03-03 05:20:12 -080072 static const UINT kPeriod = 1;
73 bool high_res = (timeBeginPeriod(kPeriod) == TIMERR_NOERROR);
Danil Chapovalov826f2e72019-02-20 18:13:09 +010074 int64_t ret = rtc::TimeMillis();
tommi5bdee472017-03-03 05:20:12 -080075 if (high_res)
76 timeEndPeriod(kPeriod);
77 return ret;
78}
tommic06b1332016-05-14 11:31:40 -070079
tommi0b942152017-03-10 09:33:53 -080080class DelayedTaskInfo {
tommif9d91542017-02-17 02:47:11 -080081 public:
tommi0b942152017-03-10 09:33:53 -080082 // Default ctor needed to support priority_queue::pop().
83 DelayedTaskInfo() {}
84 DelayedTaskInfo(uint32_t milliseconds, std::unique_ptr<QueuedTask> task)
85 : due_time_(GetTick() + milliseconds), task_(std::move(task)) {}
86 DelayedTaskInfo(DelayedTaskInfo&&) = default;
tommif9d91542017-02-17 02:47:11 -080087
tommi0b942152017-03-10 09:33:53 -080088 // Implement for priority_queue.
89 bool operator>(const DelayedTaskInfo& other) const {
90 return due_time_ > other.due_time_;
91 }
tommif9d91542017-02-17 02:47:11 -080092
tommi0b942152017-03-10 09:33:53 -080093 // Required by priority_queue::pop().
94 DelayedTaskInfo& operator=(DelayedTaskInfo&& other) = default;
95
96 // See below for why this method is const.
97 void Run() const {
98 RTC_DCHECK(due_time_);
99 task_->Run() ? task_.reset() : static_cast<void>(task_.release());
100 }
101
102 int64_t due_time() const { return due_time_; }
103
104 private:
105 int64_t due_time_ = 0; // Absolute timestamp in milliseconds.
106
107 // |task| needs to be mutable because std::priority_queue::top() returns
108 // a const reference and a key in an ordered queue must not be changed.
109 // There are two basic workarounds, one using const_cast, which would also
110 // make the key (|due_time|), non-const and the other is to make the non-key
111 // (|task|), mutable.
112 // Because of this, the |task| variable is made private and can only be
113 // mutated by calling the |Run()| method.
114 mutable std::unique_ptr<QueuedTask> task_;
115};
116
117class MultimediaTimer {
118 public:
tommi83722262017-03-15 04:36:29 -0700119 // Note: We create an event that requires manual reset.
120 MultimediaTimer() : event_(::CreateEvent(nullptr, true, false, nullptr)) {}
tommif9d91542017-02-17 02:47:11 -0800121
tommi0b942152017-03-10 09:33:53 -0800122 ~MultimediaTimer() {
123 Cancel();
124 ::CloseHandle(event_);
tommif9d91542017-02-17 02:47:11 -0800125 }
126
tommi0b942152017-03-10 09:33:53 -0800127 bool StartOneShotTimer(UINT delay_ms) {
tommif9d91542017-02-17 02:47:11 -0800128 RTC_DCHECK_EQ(0, timer_id_);
129 RTC_DCHECK(event_ != nullptr);
tommif9d91542017-02-17 02:47:11 -0800130 timer_id_ =
131 ::timeSetEvent(delay_ms, 0, reinterpret_cast<LPTIMECALLBACK>(event_), 0,
132 TIME_ONESHOT | TIME_CALLBACK_EVENT_SET);
133 return timer_id_ != 0;
134 }
135
tommi0b942152017-03-10 09:33:53 -0800136 void Cancel() {
tommif9d91542017-02-17 02:47:11 -0800137 if (timer_id_) {
138 ::timeKillEvent(timer_id_);
139 timer_id_ = 0;
140 }
Danil Chapovalovfa733932020-01-13 12:56:13 +0100141 // Now that timer is killed and not able to set the event, reset the event.
142 // Doing it in opposite order is racy because event may be set between
143 // event was reset and timer is killed leaving MultimediaTimer in surprising
144 // state where both event is set and timer is canceled.
145 ::ResetEvent(event_);
tommif9d91542017-02-17 02:47:11 -0800146 }
147
tommi0b942152017-03-10 09:33:53 -0800148 HANDLE* event_for_wait() { return &event_; }
tommif9d91542017-02-17 02:47:11 -0800149
150 private:
tommif9d91542017-02-17 02:47:11 -0800151 HANDLE event_ = nullptr;
152 MMRESULT timer_id_ = 0;
tommif9d91542017-02-17 02:47:11 -0800153
154 RTC_DISALLOW_COPY_AND_ASSIGN(MultimediaTimer);
155};
156
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100157class TaskQueueWin : public TaskQueueBase {
tommi0b942152017-03-10 09:33:53 -0800158 public:
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100159 TaskQueueWin(absl::string_view queue_name, rtc::ThreadPriority priority);
160 ~TaskQueueWin() override = default;
tommi0b942152017-03-10 09:33:53 -0800161
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100162 void Delete() override;
163 void PostTask(std::unique_ptr<QueuedTask> task) override;
164 void PostDelayedTask(std::unique_ptr<QueuedTask> task,
165 uint32_t milliseconds) override;
nisse341c8e42017-09-06 04:38:22 -0700166
167 void RunPendingTasks();
tommi0b942152017-03-10 09:33:53 -0800168
169 private:
nisse341c8e42017-09-06 04:38:22 -0700170 static void ThreadMain(void* context);
tommi0b942152017-03-10 09:33:53 -0800171
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100172 class WorkerThread : public rtc::PlatformThread {
nisse341c8e42017-09-06 04:38:22 -0700173 public:
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100174 WorkerThread(rtc::ThreadRunFunction func,
nisse341c8e42017-09-06 04:38:22 -0700175 void* obj,
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100176 absl::string_view thread_name,
177 rtc::ThreadPriority priority)
nisse341c8e42017-09-06 04:38:22 -0700178 : PlatformThread(func, obj, thread_name, priority) {}
179
180 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) {
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100181 return rtc::PlatformThread::QueueAPC(apc_function, data);
nisse341c8e42017-09-06 04:38:22 -0700182 }
tommi0b942152017-03-10 09:33:53 -0800183 };
184
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100185 void RunThreadMain();
186 bool ProcessQueuedMessages();
187 void RunDueTasks();
188 void ScheduleNextTimer();
189 void CancelTimers();
nisse341c8e42017-09-06 04:38:22 -0700190
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100191 // Since priority_queue<> by defult orders items in terms of
192 // largest->smallest, using std::less<>, and we want smallest->largest,
193 // we would like to use std::greater<> here. Alas it's only available in
194 // C++14 and later, so we roll our own compare template that that relies on
195 // operator<().
196 template <typename T>
197 struct greater {
198 bool operator()(const T& l, const T& r) { return l > r; }
nisse341c8e42017-09-06 04:38:22 -0700199 };
200
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100201 MultimediaTimer timer_;
202 std::priority_queue<DelayedTaskInfo,
203 std::vector<DelayedTaskInfo>,
204 greater<DelayedTaskInfo>>
205 timer_tasks_;
206 UINT_PTR timer_id_ = 0;
nisse341c8e42017-09-06 04:38:22 -0700207 WorkerThread thread_;
Markus Handell18523c32020-07-08 17:55:58 +0200208 Mutex pending_lock_;
danilchapa37de392017-09-09 04:17:22 -0700209 std::queue<std::unique_ptr<QueuedTask>> pending_
210 RTC_GUARDED_BY(pending_lock_);
tommi83722262017-03-15 04:36:29 -0700211 HANDLE in_queue_;
tommi0b942152017-03-10 09:33:53 -0800212};
213
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100214TaskQueueWin::TaskQueueWin(absl::string_view queue_name,
215 rtc::ThreadPriority priority)
216 : thread_(&TaskQueueWin::ThreadMain, this, queue_name, priority),
nisse341c8e42017-09-06 04:38:22 -0700217 in_queue_(::CreateEvent(nullptr, true, false, nullptr)) {
tommi83722262017-03-15 04:36:29 -0700218 RTC_DCHECK(in_queue_);
tommic06b1332016-05-14 11:31:40 -0700219 thread_.Start();
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100220 rtc::Event event(false, false);
tommic06b1332016-05-14 11:31:40 -0700221 RTC_CHECK(thread_.QueueAPC(&InitializeQueueThread,
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100222 reinterpret_cast<ULONG_PTR>(&event)));
223 event.Wait(rtc::Event::kForever);
tommic06b1332016-05-14 11:31:40 -0700224}
225
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100226void TaskQueueWin::Delete() {
tommic06b1332016-05-14 11:31:40 -0700227 RTC_DCHECK(!IsCurrent());
tommif9d91542017-02-17 02:47:11 -0800228 while (!::PostThreadMessage(thread_.GetThreadRef(), WM_QUIT, 0, 0)) {
kwiberg352444f2016-11-28 15:58:53 -0800229 RTC_CHECK_EQ(ERROR_NOT_ENOUGH_QUOTA, ::GetLastError());
tommic06b1332016-05-14 11:31:40 -0700230 Sleep(1);
231 }
232 thread_.Stop();
tommi83722262017-03-15 04:36:29 -0700233 ::CloseHandle(in_queue_);
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100234 delete this;
tommic06b1332016-05-14 11:31:40 -0700235}
236
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100237void TaskQueueWin::PostTask(std::unique_ptr<QueuedTask> task) {
Markus Handell18523c32020-07-08 17:55:58 +0200238 MutexLock lock(&pending_lock_);
tommi83722262017-03-15 04:36:29 -0700239 pending_.push(std::move(task));
240 ::SetEvent(in_queue_);
tommic06b1332016-05-14 11:31:40 -0700241}
242
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100243void TaskQueueWin::PostDelayedTask(std::unique_ptr<QueuedTask> task,
244 uint32_t milliseconds) {
tommi0b942152017-03-10 09:33:53 -0800245 if (!milliseconds) {
246 PostTask(std::move(task));
247 return;
248 }
249
250 // TODO(tommi): Avoid this allocation. It is currently here since
251 // the timestamp stored in the task info object, is a 64bit timestamp
252 // and WPARAM is 32bits in 32bit builds. Otherwise, we could pass the
253 // task pointer and timestamp as LPARAM and WPARAM.
254 auto* task_info = new DelayedTaskInfo(milliseconds, std::move(task));
255 if (!::PostThreadMessage(thread_.GetThreadRef(), WM_QUEUE_DELAYED_TASK, 0,
256 reinterpret_cast<LPARAM>(task_info))) {
257 delete task_info;
tommic06b1332016-05-14 11:31:40 -0700258 }
259}
260
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100261void TaskQueueWin::RunPendingTasks() {
tommi83722262017-03-15 04:36:29 -0700262 while (true) {
263 std::unique_ptr<QueuedTask> task;
264 {
Markus Handell18523c32020-07-08 17:55:58 +0200265 MutexLock lock(&pending_lock_);
tommi83722262017-03-15 04:36:29 -0700266 if (pending_.empty())
267 break;
268 task = std::move(pending_.front());
269 pending_.pop();
270 }
271
272 if (!task->Run())
273 task.release();
274 }
275}
276
tommic06b1332016-05-14 11:31:40 -0700277// static
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100278void TaskQueueWin::ThreadMain(void* context) {
279 static_cast<TaskQueueWin*>(context)->RunThreadMain();
tommi0b942152017-03-10 09:33:53 -0800280}
tommif9d91542017-02-17 02:47:11 -0800281
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100282void TaskQueueWin::RunThreadMain() {
283 CurrentTaskQueueSetter set_current(this);
Yves Gerey665174f2018-06-19 15:03:05 +0200284 HANDLE handles[2] = {*timer_.event_for_wait(), in_queue_};
tommib89257a2016-07-12 01:24:36 -0700285 while (true) {
tommif9d91542017-02-17 02:47:11 -0800286 // Make sure we do an alertable wait as that's required to allow APCs to run
287 // (e.g. required for InitializeQueueThread and stopping the thread in
288 // PlatformThread).
tommi0b942152017-03-10 09:33:53 -0800289 DWORD result = ::MsgWaitForMultipleObjectsEx(
tommi83722262017-03-15 04:36:29 -0700290 arraysize(handles), handles, INFINITE, QS_ALLEVENTS, MWMO_ALERTABLE);
tommib89257a2016-07-12 01:24:36 -0700291 RTC_CHECK_NE(WAIT_FAILED, result);
tommi83722262017-03-15 04:36:29 -0700292 if (result == (WAIT_OBJECT_0 + 2)) {
tommi0b942152017-03-10 09:33:53 -0800293 // There are messages in the message queue that need to be handled.
294 if (!ProcessQueuedMessages())
tommib89257a2016-07-12 01:24:36 -0700295 break;
tommi83722262017-03-15 04:36:29 -0700296 }
297
Yves Gerey665174f2018-06-19 15:03:05 +0200298 if (result == WAIT_OBJECT_0 ||
299 (!timer_tasks_.empty() &&
300 ::WaitForSingleObject(*timer_.event_for_wait(), 0) == WAIT_OBJECT_0)) {
tommi0b942152017-03-10 09:33:53 -0800301 // The multimedia timer was signaled.
302 timer_.Cancel();
tommi0b942152017-03-10 09:33:53 -0800303 RunDueTasks();
304 ScheduleNextTimer();
tommi83722262017-03-15 04:36:29 -0700305 }
306
307 if (result == (WAIT_OBJECT_0 + 1)) {
308 ::ResetEvent(in_queue_);
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100309 RunPendingTasks();
tommib89257a2016-07-12 01:24:36 -0700310 }
311 }
tommib89257a2016-07-12 01:24:36 -0700312}
tommic06b1332016-05-14 11:31:40 -0700313
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100314bool TaskQueueWin::ProcessQueuedMessages() {
tommib89257a2016-07-12 01:24:36 -0700315 MSG msg = {};
tommi83722262017-03-15 04:36:29 -0700316 // To protect against overly busy message queues, we limit the time
317 // we process tasks to a few milliseconds. If we don't do that, there's
318 // a chance that timer tasks won't ever run.
319 static const int kMaxTaskProcessingTimeMs = 500;
320 auto start = GetTick();
tommif9d91542017-02-17 02:47:11 -0800321 while (::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE) &&
tommib89257a2016-07-12 01:24:36 -0700322 msg.message != WM_QUIT) {
tommic06b1332016-05-14 11:31:40 -0700323 if (!msg.hwnd) {
324 switch (msg.message) {
tommi83722262017-03-15 04:36:29 -0700325 // TODO(tommi): Stop using this way of queueing tasks.
tommic06b1332016-05-14 11:31:40 -0700326 case WM_RUN_TASK: {
327 QueuedTask* task = reinterpret_cast<QueuedTask*>(msg.lParam);
328 if (task->Run())
329 delete task;
330 break;
331 }
332 case WM_QUEUE_DELAYED_TASK: {
tommi0b942152017-03-10 09:33:53 -0800333 std::unique_ptr<DelayedTaskInfo> info(
334 reinterpret_cast<DelayedTaskInfo*>(msg.lParam));
335 bool need_to_schedule_timers =
336 timer_tasks_.empty() ||
337 timer_tasks_.top().due_time() > info->due_time();
338 timer_tasks_.emplace(std::move(*info.get()));
339 if (need_to_schedule_timers) {
340 CancelTimers();
341 ScheduleNextTimer();
tommif9d91542017-02-17 02:47:11 -0800342 }
tommic06b1332016-05-14 11:31:40 -0700343 break;
344 }
345 case WM_TIMER: {
tommi0b942152017-03-10 09:33:53 -0800346 RTC_DCHECK_EQ(timer_id_, msg.wParam);
tommif9d91542017-02-17 02:47:11 -0800347 ::KillTimer(nullptr, msg.wParam);
tommi0b942152017-03-10 09:33:53 -0800348 timer_id_ = 0;
349 RunDueTasks();
350 ScheduleNextTimer();
tommic06b1332016-05-14 11:31:40 -0700351 break;
352 }
353 default:
354 RTC_NOTREACHED();
355 break;
356 }
357 } else {
tommif9d91542017-02-17 02:47:11 -0800358 ::TranslateMessage(&msg);
359 ::DispatchMessage(&msg);
tommic06b1332016-05-14 11:31:40 -0700360 }
tommi83722262017-03-15 04:36:29 -0700361
362 if (GetTick() > start + kMaxTaskProcessingTimeMs)
363 break;
tommic06b1332016-05-14 11:31:40 -0700364 }
tommib89257a2016-07-12 01:24:36 -0700365 return msg.message != WM_QUIT;
tommic06b1332016-05-14 11:31:40 -0700366}
tommib89257a2016-07-12 01:24:36 -0700367
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100368void TaskQueueWin::RunDueTasks() {
tommi0b942152017-03-10 09:33:53 -0800369 RTC_DCHECK(!timer_tasks_.empty());
370 auto now = GetTick();
371 do {
372 const auto& top = timer_tasks_.top();
373 if (top.due_time() > now)
374 break;
375 top.Run();
376 timer_tasks_.pop();
377 } while (!timer_tasks_.empty());
378}
379
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100380void TaskQueueWin::ScheduleNextTimer() {
tommi0b942152017-03-10 09:33:53 -0800381 RTC_DCHECK_EQ(timer_id_, 0);
382 if (timer_tasks_.empty())
383 return;
384
385 const auto& next_task = timer_tasks_.top();
386 int64_t delay_ms = std::max(0ll, next_task.due_time() - GetTick());
387 uint32_t milliseconds = rtc::dchecked_cast<uint32_t>(delay_ms);
388 if (!timer_.StartOneShotTimer(milliseconds))
389 timer_id_ = ::SetTimer(nullptr, 0, milliseconds, nullptr);
390}
391
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100392void TaskQueueWin::CancelTimers() {
tommi0b942152017-03-10 09:33:53 -0800393 timer_.Cancel();
394 if (timer_id_) {
395 ::KillTimer(nullptr, timer_id_);
396 timer_id_ = 0;
397 }
398}
399
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100400class TaskQueueWinFactory : public TaskQueueFactory {
401 public:
402 std::unique_ptr<TaskQueueBase, TaskQueueDeleter> CreateTaskQueue(
403 absl::string_view name,
404 Priority priority) const override {
405 return std::unique_ptr<TaskQueueBase, TaskQueueDeleter>(
406 new TaskQueueWin(name, TaskQueuePriorityToThreadPriority(priority)));
407 }
408};
409
410} // namespace
411
412std::unique_ptr<TaskQueueFactory> CreateTaskQueueWinFactory() {
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200413 return std::make_unique<TaskQueueWinFactory>();
nisse341c8e42017-09-06 04:38:22 -0700414}
415
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100416} // namespace webrtc