From 6df49b9d01207c379ba2f091dc5288f8ff33e21e Mon Sep 17 00:00:00 2001 From: Markus Handell Date: Wed, 17 Aug 2022 13:39:59 +0000 Subject: [PATCH] TaskQueueStdlib: remove dependency on Event::kForever being int. While transitioning to TimeDelta, WebRTC and Chromium has a different idea about what type rtc::Event::kForever is. Code can't assume rtc::Event::kForever is the same type as timed wait arguments. Bug: webrtc:14366 Change-Id: I4783c7de6d567c70b211de9aa9889417f6fafba1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272060 Reviewed-by: Mirko Bonadei Commit-Queue: Markus Handell Cr-Commit-Position: refs/heads/main@{#37810} --- rtc_base/task_queue_stdlib.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/rtc_base/task_queue_stdlib.cc b/rtc_base/task_queue_stdlib.cc index 19e7dead97..f712cfa8c7 100644 --- a/rtc_base/task_queue_stdlib.cc +++ b/rtc_base/task_queue_stdlib.cc @@ -74,7 +74,13 @@ class TaskQueueStdlib final : public TaskQueueBase { struct NextTask { bool final_task = false; absl::AnyInvocable run_task; - int64_t sleep_time_ms = rtc::Event::kForever; + // TODO(bugs.webrtc.org/14366): While transitioning to TimeDelta, WebRTC and + // Chromium has a different idea about what type rtc::Event::kForever is. + // Code can't assume rtc::Event::kForever is the same type as timed wait + // arguments. + // Change `sleep_time_ms` to be explicit type, default value + // `rtc::Event::kForever` once transition is complete. + absl::optional sleep_time_ms; }; static rtc::PlatformThread InitializeThread(TaskQueueStdlib* me, @@ -246,7 +252,15 @@ void TaskQueueStdlib::ProcessTasks() { continue; } - flag_notify_.Wait(task.sleep_time_ms); + // TODO(bugs.webrtc.org/14366): While transitioning to TimeDelta, WebRTC and + // Chromium has a different idea about what type rtc::Event::kForever is. + // Code can't assume rtc::Event::kForever is the same type as timed wait + // arguments. + // Simplify after transitioning is complete. + if (task.sleep_time_ms.has_value()) + flag_notify_.Wait(task.sleep_time_ms.value()); + else + flag_notify_.Wait(rtc::Event::kForever); } }