1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:57:35 +00:00

CEventLoop: Add wake(), a mechanism for waking up when blocked in select().

This patch generalizes the concept used in Piano to wake up the event loop
so it can react to something happening on a secondary thread.
Basically, there's a pipe who is always part of the file descriptor set we
pass to select(), and calling wake() simply writes a little to that pipe.
This commit is contained in:
Andreas Kling 2019-07-14 10:20:57 +02:00
parent f1d6a37d5d
commit 17ee548bcd
2 changed files with 23 additions and 0 deletions

View file

@ -50,6 +50,8 @@ public:
m_queued_events.append(move(other.m_queued_events));
}
static void wake();
protected:
virtual void add_file_descriptors_for_select(fd_set&, int& max_fd) { UNUSED_PARAM(max_fd); }
virtual void process_file_descriptors_after_select(const fd_set&) {}
@ -69,6 +71,8 @@ private:
bool m_exit_requested { false };
int m_exit_code { 0 };
static int s_wake_pipe_fds[2];
CLock m_lock;
struct EventLoopTimer {