rtc::Event: Finalize migration to TimeDelta.

Bug: webrtc:14366
Change-Id: Icd8792a2f9efa5609dd13da2e175042fac101d36
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272101
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Markus Handell <handellm@webrtc.org>
Auto-Submit: Markus Handell <handellm@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37844}
This commit is contained in:
Markus Handell
2022-08-19 12:42:31 +00:00
committed by WebRTC LUCI CQ
parent 99d7d6b4f6
commit 0cd0dd3b07
7 changed files with 41 additions and 61 deletions

View File

@ -50,29 +50,13 @@ class Event {
bool Wait(webrtc::TimeDelta give_up_after, webrtc::TimeDelta warn_after);
// Waits with the given timeout and a reasonable default warning timeout.
// TODO(bugs.webrtc.org/14366): De-template this after millisec-based Wait is
// removed.
template <class T>
bool Wait(T give_up_after) {
webrtc::TimeDelta duration = ToTimeDelta(give_up_after);
return Wait(duration, duration.IsPlusInfinity()
? webrtc::TimeDelta::Seconds(3)
: kForever);
bool Wait(webrtc::TimeDelta give_up_after) {
return Wait(give_up_after, give_up_after.IsPlusInfinity()
? webrtc::TimeDelta::Seconds(3)
: kForever);
}
private:
// TODO(bugs.webrtc.org/14366): Remove after millisec-based Wait is removed.
static webrtc::TimeDelta ToTimeDelta(int duration) {
// SocketServer users can get here with SocketServer::kForever which is
// -1. Mirror the definition here to avoid dependence.
constexpr int kForeverMs = -1;
return duration == kForeverMs ? kForever
: webrtc::TimeDelta::Millis(duration);
}
static webrtc::TimeDelta ToTimeDelta(webrtc::TimeDelta duration) {
return duration;
}
#if defined(WEBRTC_WIN)
HANDLE event_handle_;
#elif defined(WEBRTC_POSIX)