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 <mbonadei@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37810}
This commit is contained in:
Markus Handell 2022-08-17 13:39:59 +00:00 committed by WebRTC LUCI CQ
parent 3d38cd3c41
commit 6df49b9d01

View file

@ -74,7 +74,13 @@ class TaskQueueStdlib final : public TaskQueueBase {
struct NextTask { struct NextTask {
bool final_task = false; bool final_task = false;
absl::AnyInvocable<void() &&> run_task; absl::AnyInvocable<void() &&> 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<int64_t> sleep_time_ms;
}; };
static rtc::PlatformThread InitializeThread(TaskQueueStdlib* me, static rtc::PlatformThread InitializeThread(TaskQueueStdlib* me,
@ -246,7 +252,15 @@ void TaskQueueStdlib::ProcessTasks() {
continue; 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);
} }
} }