blob: 8bfe5e5c445ba3e64d3c619c12060ec3fa0b73a6 [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:
Guido Urdaneta793bac52021-05-06 13:12:47 +000059 return rtc::kRealtimePriority;
Danil Chapovalov826f2e72019-02-20 18:13:09 +010060 case TaskQueueFactory::Priority::LOW:
Guido Urdaneta793bac52021-05-06 13:12:47 +000061 return rtc::kLowPriority;
Danil Chapovalov826f2e72019-02-20 18:13:09 +010062 case TaskQueueFactory::Priority::NORMAL:
Guido Urdaneta793bac52021-05-06 13:12:47 +000063 return rtc::kNormalPriority;
64 default:
65 RTC_NOTREACHED();
66 break;
tommic9bb7912017-02-24 10:42:14 -080067 }
Guido Urdaneta793bac52021-05-06 13:12:47 +000068 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:
Guido Urdaneta793bac52021-05-06 13:12:47 +0000170 static void ThreadMain(void* context);
171
172 class WorkerThread : public rtc::PlatformThread {
173 public:
174 WorkerThread(rtc::ThreadRunFunction func,
175 void* obj,
176 absl::string_view thread_name,
177 rtc::ThreadPriority priority)
178 : PlatformThread(func,
179 obj,
180 thread_name,
181 rtc::ThreadAttributes().SetPriority(priority)) {}
182
183 bool QueueAPC(PAPCFUNC apc_function, ULONG_PTR data) {
184 return rtc::PlatformThread::QueueAPC(apc_function, data);
185 }
186 };
187
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100188 void RunThreadMain();
189 bool ProcessQueuedMessages();
190 void RunDueTasks();
191 void ScheduleNextTimer();
192 void CancelTimers();
nisse341c8e42017-09-06 04:38:22 -0700193
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100194 // Since priority_queue<> by defult orders items in terms of
195 // largest->smallest, using std::less<>, and we want smallest->largest,
196 // we would like to use std::greater<> here. Alas it's only available in
197 // C++14 and later, so we roll our own compare template that that relies on
198 // operator<().
199 template <typename T>
200 struct greater {
201 bool operator()(const T& l, const T& r) { return l > r; }
nisse341c8e42017-09-06 04:38:22 -0700202 };
203
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100204 MultimediaTimer timer_;
205 std::priority_queue<DelayedTaskInfo,
206 std::vector<DelayedTaskInfo>,
207 greater<DelayedTaskInfo>>
208 timer_tasks_;
209 UINT_PTR timer_id_ = 0;
Guido Urdaneta793bac52021-05-06 13:12:47 +0000210 WorkerThread thread_;
Markus Handell18523c32020-07-08 17:55:58 +0200211 Mutex pending_lock_;
danilchapa37de392017-09-09 04:17:22 -0700212 std::queue<std::unique_ptr<QueuedTask>> pending_
213 RTC_GUARDED_BY(pending_lock_);
tommi83722262017-03-15 04:36:29 -0700214 HANDLE in_queue_;
tommi0b942152017-03-10 09:33:53 -0800215};
216
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100217TaskQueueWin::TaskQueueWin(absl::string_view queue_name,
218 rtc::ThreadPriority priority)
Guido Urdaneta793bac52021-05-06 13:12:47 +0000219 : thread_(&TaskQueueWin::ThreadMain, this, queue_name, priority),
220 in_queue_(::CreateEvent(nullptr, true, false, nullptr)) {
tommi83722262017-03-15 04:36:29 -0700221 RTC_DCHECK(in_queue_);
Guido Urdaneta793bac52021-05-06 13:12:47 +0000222 thread_.Start();
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100223 rtc::Event event(false, false);
tommic06b1332016-05-14 11:31:40 -0700224 RTC_CHECK(thread_.QueueAPC(&InitializeQueueThread,
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100225 reinterpret_cast<ULONG_PTR>(&event)));
226 event.Wait(rtc::Event::kForever);
tommic06b1332016-05-14 11:31:40 -0700227}
228
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100229void TaskQueueWin::Delete() {
tommic06b1332016-05-14 11:31:40 -0700230 RTC_DCHECK(!IsCurrent());
Guido Urdaneta793bac52021-05-06 13:12:47 +0000231 while (!::PostThreadMessage(thread_.GetThreadRef(), WM_QUIT, 0, 0)) {
kwiberg352444f2016-11-28 15:58:53 -0800232 RTC_CHECK_EQ(ERROR_NOT_ENOUGH_QUOTA, ::GetLastError());
tommic06b1332016-05-14 11:31:40 -0700233 Sleep(1);
234 }
Guido Urdaneta793bac52021-05-06 13:12:47 +0000235 thread_.Stop();
tommi83722262017-03-15 04:36:29 -0700236 ::CloseHandle(in_queue_);
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100237 delete this;
tommic06b1332016-05-14 11:31:40 -0700238}
239
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100240void TaskQueueWin::PostTask(std::unique_ptr<QueuedTask> task) {
Markus Handell18523c32020-07-08 17:55:58 +0200241 MutexLock lock(&pending_lock_);
tommi83722262017-03-15 04:36:29 -0700242 pending_.push(std::move(task));
243 ::SetEvent(in_queue_);
tommic06b1332016-05-14 11:31:40 -0700244}
245
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100246void TaskQueueWin::PostDelayedTask(std::unique_ptr<QueuedTask> task,
247 uint32_t milliseconds) {
tommi0b942152017-03-10 09:33:53 -0800248 if (!milliseconds) {
249 PostTask(std::move(task));
250 return;
251 }
252
253 // TODO(tommi): Avoid this allocation. It is currently here since
254 // the timestamp stored in the task info object, is a 64bit timestamp
255 // and WPARAM is 32bits in 32bit builds. Otherwise, we could pass the
256 // task pointer and timestamp as LPARAM and WPARAM.
257 auto* task_info = new DelayedTaskInfo(milliseconds, std::move(task));
Guido Urdaneta793bac52021-05-06 13:12:47 +0000258 if (!::PostThreadMessage(thread_.GetThreadRef(), WM_QUEUE_DELAYED_TASK, 0,
tommi0b942152017-03-10 09:33:53 -0800259 reinterpret_cast<LPARAM>(task_info))) {
260 delete task_info;
tommic06b1332016-05-14 11:31:40 -0700261 }
262}
263
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100264void TaskQueueWin::RunPendingTasks() {
tommi83722262017-03-15 04:36:29 -0700265 while (true) {
266 std::unique_ptr<QueuedTask> task;
267 {
Markus Handell18523c32020-07-08 17:55:58 +0200268 MutexLock lock(&pending_lock_);
tommi83722262017-03-15 04:36:29 -0700269 if (pending_.empty())
270 break;
271 task = std::move(pending_.front());
272 pending_.pop();
273 }
274
275 if (!task->Run())
276 task.release();
277 }
278}
279
Guido Urdaneta793bac52021-05-06 13:12:47 +0000280// static
281void TaskQueueWin::ThreadMain(void* context) {
282 static_cast<TaskQueueWin*>(context)->RunThreadMain();
283}
284
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100285void TaskQueueWin::RunThreadMain() {
286 CurrentTaskQueueSetter set_current(this);
Yves Gerey665174f2018-06-19 15:03:05 +0200287 HANDLE handles[2] = {*timer_.event_for_wait(), in_queue_};
tommib89257a2016-07-12 01:24:36 -0700288 while (true) {
tommif9d91542017-02-17 02:47:11 -0800289 // Make sure we do an alertable wait as that's required to allow APCs to run
290 // (e.g. required for InitializeQueueThread and stopping the thread in
291 // PlatformThread).
tommi0b942152017-03-10 09:33:53 -0800292 DWORD result = ::MsgWaitForMultipleObjectsEx(
tommi83722262017-03-15 04:36:29 -0700293 arraysize(handles), handles, INFINITE, QS_ALLEVENTS, MWMO_ALERTABLE);
tommib89257a2016-07-12 01:24:36 -0700294 RTC_CHECK_NE(WAIT_FAILED, result);
tommi83722262017-03-15 04:36:29 -0700295 if (result == (WAIT_OBJECT_0 + 2)) {
tommi0b942152017-03-10 09:33:53 -0800296 // There are messages in the message queue that need to be handled.
297 if (!ProcessQueuedMessages())
tommib89257a2016-07-12 01:24:36 -0700298 break;
tommi83722262017-03-15 04:36:29 -0700299 }
300
Yves Gerey665174f2018-06-19 15:03:05 +0200301 if (result == WAIT_OBJECT_0 ||
302 (!timer_tasks_.empty() &&
303 ::WaitForSingleObject(*timer_.event_for_wait(), 0) == WAIT_OBJECT_0)) {
tommi0b942152017-03-10 09:33:53 -0800304 // The multimedia timer was signaled.
305 timer_.Cancel();
tommi0b942152017-03-10 09:33:53 -0800306 RunDueTasks();
307 ScheduleNextTimer();
tommi83722262017-03-15 04:36:29 -0700308 }
309
310 if (result == (WAIT_OBJECT_0 + 1)) {
311 ::ResetEvent(in_queue_);
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100312 RunPendingTasks();
tommib89257a2016-07-12 01:24:36 -0700313 }
314 }
tommib89257a2016-07-12 01:24:36 -0700315}
tommic06b1332016-05-14 11:31:40 -0700316
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100317bool TaskQueueWin::ProcessQueuedMessages() {
tommib89257a2016-07-12 01:24:36 -0700318 MSG msg = {};
tommi83722262017-03-15 04:36:29 -0700319 // To protect against overly busy message queues, we limit the time
320 // we process tasks to a few milliseconds. If we don't do that, there's
321 // a chance that timer tasks won't ever run.
322 static const int kMaxTaskProcessingTimeMs = 500;
323 auto start = GetTick();
tommif9d91542017-02-17 02:47:11 -0800324 while (::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE) &&
tommib89257a2016-07-12 01:24:36 -0700325 msg.message != WM_QUIT) {
tommic06b1332016-05-14 11:31:40 -0700326 if (!msg.hwnd) {
327 switch (msg.message) {
tommi83722262017-03-15 04:36:29 -0700328 // TODO(tommi): Stop using this way of queueing tasks.
tommic06b1332016-05-14 11:31:40 -0700329 case WM_RUN_TASK: {
330 QueuedTask* task = reinterpret_cast<QueuedTask*>(msg.lParam);
331 if (task->Run())
332 delete task;
333 break;
334 }
335 case WM_QUEUE_DELAYED_TASK: {
tommi0b942152017-03-10 09:33:53 -0800336 std::unique_ptr<DelayedTaskInfo> info(
337 reinterpret_cast<DelayedTaskInfo*>(msg.lParam));
338 bool need_to_schedule_timers =
339 timer_tasks_.empty() ||
340 timer_tasks_.top().due_time() > info->due_time();
341 timer_tasks_.emplace(std::move(*info.get()));
342 if (need_to_schedule_timers) {
343 CancelTimers();
344 ScheduleNextTimer();
tommif9d91542017-02-17 02:47:11 -0800345 }
tommic06b1332016-05-14 11:31:40 -0700346 break;
347 }
348 case WM_TIMER: {
tommi0b942152017-03-10 09:33:53 -0800349 RTC_DCHECK_EQ(timer_id_, msg.wParam);
tommif9d91542017-02-17 02:47:11 -0800350 ::KillTimer(nullptr, msg.wParam);
tommi0b942152017-03-10 09:33:53 -0800351 timer_id_ = 0;
352 RunDueTasks();
353 ScheduleNextTimer();
tommic06b1332016-05-14 11:31:40 -0700354 break;
355 }
356 default:
357 RTC_NOTREACHED();
358 break;
359 }
360 } else {
tommif9d91542017-02-17 02:47:11 -0800361 ::TranslateMessage(&msg);
362 ::DispatchMessage(&msg);
tommic06b1332016-05-14 11:31:40 -0700363 }
tommi83722262017-03-15 04:36:29 -0700364
365 if (GetTick() > start + kMaxTaskProcessingTimeMs)
366 break;
tommic06b1332016-05-14 11:31:40 -0700367 }
tommib89257a2016-07-12 01:24:36 -0700368 return msg.message != WM_QUIT;
tommic06b1332016-05-14 11:31:40 -0700369}
tommib89257a2016-07-12 01:24:36 -0700370
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100371void TaskQueueWin::RunDueTasks() {
tommi0b942152017-03-10 09:33:53 -0800372 RTC_DCHECK(!timer_tasks_.empty());
373 auto now = GetTick();
374 do {
375 const auto& top = timer_tasks_.top();
376 if (top.due_time() > now)
377 break;
378 top.Run();
379 timer_tasks_.pop();
380 } while (!timer_tasks_.empty());
381}
382
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100383void TaskQueueWin::ScheduleNextTimer() {
tommi0b942152017-03-10 09:33:53 -0800384 RTC_DCHECK_EQ(timer_id_, 0);
385 if (timer_tasks_.empty())
386 return;
387
388 const auto& next_task = timer_tasks_.top();
389 int64_t delay_ms = std::max(0ll, next_task.due_time() - GetTick());
390 uint32_t milliseconds = rtc::dchecked_cast<uint32_t>(delay_ms);
391 if (!timer_.StartOneShotTimer(milliseconds))
392 timer_id_ = ::SetTimer(nullptr, 0, milliseconds, nullptr);
393}
394
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100395void TaskQueueWin::CancelTimers() {
tommi0b942152017-03-10 09:33:53 -0800396 timer_.Cancel();
397 if (timer_id_) {
398 ::KillTimer(nullptr, timer_id_);
399 timer_id_ = 0;
400 }
401}
402
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100403class TaskQueueWinFactory : public TaskQueueFactory {
404 public:
405 std::unique_ptr<TaskQueueBase, TaskQueueDeleter> CreateTaskQueue(
406 absl::string_view name,
407 Priority priority) const override {
408 return std::unique_ptr<TaskQueueBase, TaskQueueDeleter>(
409 new TaskQueueWin(name, TaskQueuePriorityToThreadPriority(priority)));
410 }
411};
412
413} // namespace
414
415std::unique_ptr<TaskQueueFactory> CreateTaskQueueWinFactory() {
Mirko Bonadei317a1f02019-09-17 17:06:18 +0200416 return std::make_unique<TaskQueueWinFactory>();
nisse341c8e42017-09-06 04:38:22 -0700417}
418
Danil Chapovalov826f2e72019-02-20 18:13:09 +0100419} // namespace webrtc