ladybird/Userland/Libraries/LibCore/Notifier.h
Andreas Kling 411d36719e LibCore: Simplify Core::Notifier by only allowing one event type
Not a single client of this API actually used the event mask feature to
listen for readability AND writability.

Let's simplify the API and have only one hook: on_activation.
2023-04-25 14:48:40 +02:00

46 lines
783 B
C++

/*
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <LibCore/Object.h>
namespace Core {
class Notifier final : public Object {
C_OBJECT(Notifier);
public:
enum class Type {
None,
Read,
Write,
Exceptional,
};
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) { m_type = type; }
void event(Core::Event&) override;
private:
Notifier(int fd, Type type, Object* parent = nullptr);
int m_fd { -1 };
Type m_type { Type::None };
};
}