diff options
Diffstat (limited to 'Userland/Libraries/LibCore/EventLoop.cpp')
-rw-r--r-- | Userland/Libraries/LibCore/EventLoop.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index 2c2a9f6fe1..42734be04d 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -302,7 +302,8 @@ private: }; EventLoop::EventLoop([[maybe_unused]] MakeInspectable make_inspectable) - : m_private(make<Private>()) + : m_wake_pipe_fds(&s_wake_pipe_fds) + , m_private(make<Private>()) { #ifdef __serenity__ if (!s_global_initializers_ran) { @@ -487,11 +488,13 @@ size_t EventLoop::pump(WaitMode mode) return processed_events; } -void EventLoop::post_event(Object& receiver, NonnullOwnPtr<Event>&& event) +void EventLoop::post_event(Object& receiver, NonnullOwnPtr<Event>&& event, ShouldWake should_wake) { Threading::MutexLocker lock(m_private->lock); dbgln_if(EVENTLOOP_DEBUG, "Core::EventLoop::post_event: ({}) << receiver={}, event={}", m_queued_events.size(), receiver, event); m_queued_events.empend(receiver, move(event)); + if (should_wake == ShouldWake::Yes) + wake(); } SignalHandlers::SignalHandlers(int signo, void (*handle_signal)(int)) @@ -839,10 +842,16 @@ void EventLoop::unregister_notifier(Badge<Notifier>, Notifier& notifier) s_notifiers->remove(¬ifier); } +void EventLoop::wake_current() +{ + EventLoop::current().wake(); +} + void EventLoop::wake() { + dbgln_if(EVENTLOOP_DEBUG, "Core::EventLoop::wake()"); int wake_event = 0; - int nwritten = write(s_wake_pipe_fds[1], &wake_event, sizeof(wake_event)); + int nwritten = write((*m_wake_pipe_fds)[1], &wake_event, sizeof(wake_event)); if (nwritten < 0) { perror("EventLoop::wake: write"); VERIFY_NOT_REACHED(); |