SocketServer: Migrate Wait/kForever to TimeDelta.

Bug: webrtc:13756
Change-Id: Ie36ca38b1ab336742231b101ef7bb5ccf3735659
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272102
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37903}
This commit is contained in:
Markus Handell
2022-08-25 11:40:13 +00:00
committed by WebRTC LUCI CQ
parent e7e3d5925a
commit 9a21c49337
20 changed files with 80 additions and 50 deletions

View File

@ -11,6 +11,7 @@
#ifndef RTC_BASE_PHYSICAL_SOCKET_SERVER_H_
#define RTC_BASE_PHYSICAL_SOCKET_SERVER_H_
#include "api/units/time_delta.h"
#if defined(WEBRTC_POSIX) && defined(WEBRTC_LINUX)
#include <sys/epoll.h>
#define WEBRTC_USE_EPOLL 1
@ -74,7 +75,7 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer {
virtual Socket* WrapSocket(SOCKET s);
// SocketServer:
bool Wait(int cms, bool process_io) override;
bool Wait(webrtc::TimeDelta max_wait_duration, bool process_io) override;
void WakeUp() override;
void Add(Dispatcher* dispatcher);
@ -84,16 +85,19 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer {
private:
// The number of events to process with one call to "epoll_wait".
static constexpr size_t kNumEpollEvents = 128;
// A local historical definition of "foreverness", in milliseconds.
static constexpr int kForeverMs = -1;
static int ToCmsWait(webrtc::TimeDelta max_wait_duration);
#if defined(WEBRTC_POSIX)
bool WaitSelect(int cms, bool process_io);
bool WaitSelect(int cmsWait, bool process_io);
#endif // WEBRTC_POSIX
#if defined(WEBRTC_USE_EPOLL)
void AddEpoll(Dispatcher* dispatcher, uint64_t key);
void RemoveEpoll(Dispatcher* dispatcher);
void UpdateEpoll(Dispatcher* dispatcher, uint64_t key);
bool WaitEpoll(int cms);
bool WaitPoll(int cms, Dispatcher* dispatcher);
bool WaitEpoll(int cmsWait);
bool WaitPoll(int cmsWait, Dispatcher* dispatcher);
// This array is accessed in isolation by a thread calling into Wait().
// It's useless to use a SequenceChecker to guard it because a socket