ladybird/Libraries/LibCore/Notifier.h
ayeteadoe 4fb1ba0193 LibCore: Remove unused NotifierActivationEvent fd() and type() methods
In 11b8bbe one thing that was claimed was that we now properly set the
Notifier's actual fd on the NotifierActivationEvent. It turns out that
claim was false because a crucial step was forgotten: actually set the
m_notifier_fd when registering. Despite that mistake, it ultimately was
irrelevant as the methods on NotifierActivationEvent are currently
unused code. We were posting the event to the correct Notifier receiver
so the on_activation was still getting invoked.

Given they are unused, NotifierActivationEvent can be defined the same
way as TimerEvent is, where we just pass the event type enum to the
Event base class. Additionally, NotificationType can be moved to
the Notifier header as this enum is now always used in the context of
creating or using a Notifier instance.
2025-11-22 09:47:25 +01:00

58 lines
1.1 KiB
C++

/*
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <LibCore/Event.h>
#include <LibCore/EventReceiver.h>
#include <pthread.h>
namespace Core {
enum class NotificationType : u8 {
None = 0,
Read = 1,
Write = 2,
HangUp = 4,
Error = 8,
};
AK_ENUM_BITWISE_OPERATORS(NotificationType);
class Notifier final : public EventReceiver {
C_OBJECT(Notifier);
public:
using Type = NotificationType;
virtual ~Notifier() override;
void set_enabled(bool);
Function<void()> on_activation;
void close();
int fd() const { return m_fd; }
Type type() const { return m_type; }
void set_type(Type type);
void event(Core::Event&) override;
void set_owner_thread(pthread_t owner_thread) { m_owner_thread = owner_thread; }
pthread_t owner_thread() const { return m_owner_thread; }
private:
Notifier(int fd, Type type);
pthread_t m_owner_thread {};
int m_fd { -1 };
Type m_type { Type::None };
bool m_is_enabled { false };
};
}