mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
CNotifier: Provide a way to unregister a notifier temporarily
This commit is contained in:
parent
3dac1f8ac5
commit
7bf420d83d
Notes:
sideshowbarker
2024-07-19 13:14:36 +09:00
Author: https://github.com/rburchell
Commit: 7bf420d83d
Pull-request: https://github.com/SerenityOS/serenity/pull/317
2 changed files with 12 additions and 2 deletions
|
@ -6,10 +6,18 @@ CNotifier::CNotifier(int fd, unsigned event_mask)
|
||||||
: m_fd(fd)
|
: m_fd(fd)
|
||||||
, m_event_mask(event_mask)
|
, m_event_mask(event_mask)
|
||||||
{
|
{
|
||||||
CEventLoop::register_notifier({}, *this);
|
set_enabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CNotifier::~CNotifier()
|
CNotifier::~CNotifier()
|
||||||
{
|
{
|
||||||
CEventLoop::unregister_notifier({}, *this);
|
set_enabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNotifier::set_enabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
CEventLoop::register_notifier({}, *this);
|
||||||
|
else
|
||||||
|
CEventLoop::unregister_notifier({}, *this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ public:
|
||||||
CNotifier(int fd, unsigned event_mask);
|
CNotifier(int fd, unsigned event_mask);
|
||||||
~CNotifier();
|
~CNotifier();
|
||||||
|
|
||||||
|
void set_enabled(bool);
|
||||||
|
|
||||||
Function<void()> on_ready_to_read;
|
Function<void()> on_ready_to_read;
|
||||||
Function<void()> on_ready_to_write;
|
Function<void()> on_ready_to_write;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue