diff options
author | Andreas Kling <kling@serenityos.org> | 2021-08-25 19:59:45 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-26 00:54:27 +0200 |
commit | 67a0fa2b78fdf07c23f43ad84f95063959afda13 (patch) | |
tree | 0533e7a1c2ed0351c438d9ee39e93ece053e627f /Userland/Libraries/LibCore | |
parent | 82d8cd2b87ab4fb0eb60fd763517ab950c1b5faf (diff) | |
download | serenity-67a0fa2b78fdf07c23f43ad84f95063959afda13.zip |
LibCore: Add Core::EventLoop::has_been_instantiated()
This static bool getter can be used to VERIFY that an event loop exists,
in situations where one is expected.
This is helpful if the absence of an event loop would generate strange
and/or loud errors that don't immediately point to this as a cause.
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r-- | Userland/Libraries/LibCore/EventLoop.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/EventLoop.h | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index 15f1869515..436aba6ee5 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -62,6 +62,11 @@ static HashTable<Notifier*>* s_notifiers; int EventLoop::s_wake_pipe_fds[2]; static RefPtr<InspectorServerConnection> s_inspector_server_connection; +bool EventLoop::has_been_instantiated() +{ + return s_main_event_loop; +} + class SignalHandlers : public RefCounted<SignalHandlers> { AK_MAKE_NONCOPYABLE(SignalHandlers); AK_MAKE_NONMOVABLE(SignalHandlers); diff --git a/Userland/Libraries/LibCore/EventLoop.h b/Userland/Libraries/LibCore/EventLoop.h index c0483c79df..116d23c023 100644 --- a/Userland/Libraries/LibCore/EventLoop.h +++ b/Userland/Libraries/LibCore/EventLoop.h @@ -74,6 +74,8 @@ public: }; static void notify_forked(ForkEvent); + static bool has_been_instantiated(); + private: void wait_for_event(WaitMode); Optional<Time> get_next_timer_expiration(); |