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

LibCore: Allow listening for multiple conditions using a single Notifier

While on it, implement currently unused Notifier::set_type correctly
(but not efficiently) by re-registering Notifier in the EventLoop.
This commit is contained in:
Dan Klishch 2024-02-01 20:21:15 -05:00 committed by Andrew Kaster
parent 5d1657f57f
commit 77e4f0d7d8
6 changed files with 44 additions and 20 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/Function.h>
#include <LibCore/Event.h>
#include <LibCore/EventReceiver.h>
namespace Core {
@ -15,12 +16,7 @@ class Notifier final : public EventReceiver {
C_OBJECT(Notifier);
public:
enum class Type {
None,
Read,
Write,
Exceptional,
};
using Type = NotificationType;
virtual ~Notifier() override;
@ -32,7 +28,7 @@ public:
int fd() const { return m_fd; }
Type type() const { return m_type; }
void set_type(Type type) { m_type = type; }
void set_type(Type type);
void event(Core::Event&) override;
@ -40,6 +36,7 @@ private:
Notifier(int fd, Type type, EventReceiver* parent = nullptr);
int m_fd { -1 };
bool m_is_enabled { false };
Type m_type { Type::None };
};