mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
CEventLoop: Don't bother looking through fds when select() returns 0.
If it returns 0 that just means we hit the timeout. I suppose we could skip the timer checks if there are a non-zero number of fds marked as well, but I'm not sure that's a great idea since it will add some latency.
This commit is contained in:
parent
848044b74c
commit
800242ed4e
1 changed files with 5 additions and 2 deletions
|
@ -199,8 +199,8 @@ void CEventLoop::wait_for_event(WaitMode mode)
|
||||||
should_wait_forever = false;
|
should_wait_forever = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rc = select(max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
|
int marked_fd_count = select(max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
|
||||||
if (rc < 0) {
|
if (marked_fd_count < 0) {
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,6 +224,9 @@ void CEventLoop::wait_for_event(WaitMode mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!marked_fd_count)
|
||||||
|
return;
|
||||||
|
|
||||||
for (auto& notifier : *s_notifiers) {
|
for (auto& notifier : *s_notifiers) {
|
||||||
if (FD_ISSET(notifier->fd(), &rfds)) {
|
if (FD_ISSET(notifier->fd(), &rfds)) {
|
||||||
if (notifier->on_ready_to_read)
|
if (notifier->on_ready_to_read)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue