net: introduce Sock::WaitMany()

It allows waiting concurrently on more than one socket. Being a
`virtual` `Sock` method it can be overriden by tests.

Will be used to replace `CConnman::SocketEvents()`.
This commit is contained in:
Vasil Dimov
2021-05-04 16:24:57 +02:00
parent cc74459768
commit ae263460ba
5 changed files with 152 additions and 50 deletions

View File

@@ -162,6 +162,15 @@ public:
return true;
}
bool WaitMany(std::chrono::milliseconds timeout, EventsPerSock& events_per_sock) const override
{
for (auto& [sock, events] : events_per_sock) {
(void)sock;
events.occurred = events.requested;
}
return true;
}
private:
const std::string m_contents;
mutable size_t m_consumed;