diff --git a/Libraries/LibCore/CNotifier.cpp b/Libraries/LibCore/CNotifier.cpp index c124191ac1..d042a579ca 100644 --- a/Libraries/LibCore/CNotifier.cpp +++ b/Libraries/LibCore/CNotifier.cpp @@ -6,10 +6,18 @@ CNotifier::CNotifier(int fd, unsigned event_mask) : m_fd(fd) , m_event_mask(event_mask) { - CEventLoop::register_notifier({}, *this); + set_enabled(true); } 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); } diff --git a/Libraries/LibCore/CNotifier.h b/Libraries/LibCore/CNotifier.h index 196cad8388..7ef1651914 100644 --- a/Libraries/LibCore/CNotifier.h +++ b/Libraries/LibCore/CNotifier.h @@ -13,6 +13,8 @@ public: CNotifier(int fd, unsigned event_mask); ~CNotifier(); + void set_enabled(bool); + Function on_ready_to_read; Function on_ready_to_write;