summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/EventLoopImplementationUnix.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-04-25 17:38:48 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-25 18:01:35 +0200
commit7b963e1e98b095dcd52eac8169e5c366895e3de7 (patch)
tree080ec9c8610c01700dee2fe815bb56b79eea81d1 /Userland/Libraries/LibCore/EventLoopImplementationUnix.h
parentc21eb30a2b80a7e5bc6fece3da3f4bc68e6997cd (diff)
downloadserenity-7b963e1e98b095dcd52eac8169e5c366895e3de7.zip
LibCore+Ladybird: Add EventLoopManager interface for persistent state
Things such as timers and notifiers aren't specific to one instance of Core::EventLoop, so let's not tie them down to EventLoopImplementation. Instead, move those APIs + signals & a few other things to a new EventLoopManager interface. EventLoopManager also knows how to create a new EventLoopImplementation object.
Diffstat (limited to 'Userland/Libraries/LibCore/EventLoopImplementationUnix.h')
-rw-r--r--Userland/Libraries/LibCore/EventLoopImplementationUnix.h42
1 files changed, 27 insertions, 15 deletions
diff --git a/Userland/Libraries/LibCore/EventLoopImplementationUnix.h b/Userland/Libraries/LibCore/EventLoopImplementationUnix.h
index 629e7de710..9e0c9cfe78 100644
--- a/Userland/Libraries/LibCore/EventLoopImplementationUnix.h
+++ b/Userland/Libraries/LibCore/EventLoopImplementationUnix.h
@@ -10,18 +10,11 @@
namespace Core {
-class EventLoopImplementationUnix final : public EventLoopImplementation {
+class EventLoopManagerUnix final : public EventLoopManager {
public:
- static NonnullOwnPtr<EventLoopImplementationUnix> create() { return make<EventLoopImplementationUnix>(); }
-
- EventLoopImplementationUnix();
- virtual ~EventLoopImplementationUnix();
+ virtual ~EventLoopManagerUnix() override;
- virtual int exec() override;
- virtual size_t pump(PumpMode) override;
- virtual void quit(int) override;
-
- virtual void wake() override;
+ virtual NonnullOwnPtr<EventLoopImplementation> make_implementation() override;
virtual void deferred_invoke(Function<void()>) override;
@@ -33,18 +26,37 @@ public:
virtual void did_post_event() override;
- virtual void unquit() override;
- virtual bool was_exit_requested() const override;
- virtual void notify_forked_and_in_child() override;
virtual int register_signal(int signal_number, Function<void(int)> handler) override;
virtual void unregister_signal(int handler_id) override;
+ virtual void wake() override;
+
+ void wait_for_events(EventLoopImplementation::PumpMode);
+ static Optional<Time> get_next_timer_expiration();
+
private:
- void wait_for_events(PumpMode);
void dispatch_signal(int signal_number);
static void handle_signal(int signal_number);
- static Optional<Time> get_next_timer_expiration();
+};
+class EventLoopImplementationUnix final : public EventLoopImplementation {
+public:
+ static NonnullOwnPtr<EventLoopImplementationUnix> create() { return make<EventLoopImplementationUnix>(); }
+
+ EventLoopImplementationUnix();
+ virtual ~EventLoopImplementationUnix();
+
+ virtual int exec() override;
+ virtual size_t pump(PumpMode) override;
+ virtual void quit(int) override;
+
+ virtual void wake() override;
+
+ virtual void unquit() override;
+ virtual bool was_exit_requested() const override;
+ virtual void notify_forked_and_in_child() override;
+
+private:
bool m_exit_requested { false };
int m_exit_code { 0 };