LibGUI: Yield (using select()) in GEventLoop::wait_for_specific_event().

This is factored a bit stupidly. It would be nicer to just have the
read() in drain_events_from_server() be blocking, but the fd is opened
with O_NONBLOCK right now.

This makes everything run real snappy once again. :^)
This commit is contained in:
Andreas Kling 2019-02-14 10:06:41 +01:00
parent 222a6f7bbc
commit 427df5f312
Notes: sideshowbarker 2024-07-19 15:45:13 +09:00

View file

@ -365,6 +365,12 @@ bool GEventLoop::post_message_to_server(const GUI_ClientMessage& message)
bool GEventLoop::wait_for_specific_event(GUI_ServerMessage::Type type, GUI_ServerMessage& event)
{
for (;;) {
fd_set rfds;
FD_ZERO(&rfds);
FD_SET(m_event_fd, &rfds);
int rc = select(m_event_fd + 1, &rfds, nullptr, nullptr, nullptr);
ASSERT(rc > 0);
ASSERT(FD_ISSET(m_event_fd, &rfds));
bool success = drain_messages_from_server();
if (!success)
return false;