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:
parent
5d1657f57f
commit
77e4f0d7d8
6 changed files with 44 additions and 20 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue