1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:37: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/EnumBits.h>
#include <AK/Function.h>
#include <AK/Types.h>
#include <AK/WeakPtr.h>
@ -78,19 +79,30 @@ private:
int m_timer_id;
};
enum class NotificationType {
None = 0,
Read = 1,
Write = 2,
};
AK_ENUM_BITWISE_OPERATORS(NotificationType);
class NotifierActivationEvent final : public Event {
public:
explicit NotifierActivationEvent(int fd)
explicit NotifierActivationEvent(int fd, NotificationType type)
: Event(Event::NotifierActivation)
, m_fd(fd)
, m_type(type)
{
}
~NotifierActivationEvent() = default;
int fd() const { return m_fd; }
NotificationType type() const { return m_type; }
private:
int m_fd;
NotificationType m_type;
};
class ChildEvent final : public Event {