mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +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
Notes:
sideshowbarker
2024-07-17 06:29:49 +09:00
Author: https://github.com/DanShaders
Commit: 77e4f0d7d8
Pull-request: https://github.com/SerenityOS/serenity/pull/23046
Reviewed-by: https://github.com/ADKaster
6 changed files with 44 additions and 20 deletions
|
@ -157,12 +157,10 @@ retry:
|
|||
add_fd_to_set(thread_data.wake_pipe_fds[0], read_fds);
|
||||
|
||||
for (auto& notifier : thread_data.notifiers) {
|
||||
if (notifier->type() == Notifier::Type::Read)
|
||||
if (has_flag(notifier->type(), Notifier::Type::Read))
|
||||
add_fd_to_set(notifier->fd(), read_fds);
|
||||
if (notifier->type() == Notifier::Type::Write)
|
||||
if (has_flag(notifier->type(), Notifier::Type::Write))
|
||||
add_fd_to_set(notifier->fd(), write_fds);
|
||||
if (notifier->type() == Notifier::Type::Exceptional)
|
||||
TODO();
|
||||
}
|
||||
|
||||
bool has_pending_events = ThreadEventQueue::current().has_pending_events();
|
||||
|
@ -257,12 +255,14 @@ try_select_again:
|
|||
|
||||
// Handle file system notifiers by making them normal events.
|
||||
for (auto& notifier : thread_data.notifiers) {
|
||||
if (notifier->type() == Notifier::Type::Read && FD_ISSET(notifier->fd(), &read_fds)) {
|
||||
ThreadEventQueue::current().post_event(*notifier, make<NotifierActivationEvent>(notifier->fd()));
|
||||
}
|
||||
if (notifier->type() == Notifier::Type::Write && FD_ISSET(notifier->fd(), &write_fds)) {
|
||||
ThreadEventQueue::current().post_event(*notifier, make<NotifierActivationEvent>(notifier->fd()));
|
||||
}
|
||||
auto type = NotificationType::None;
|
||||
if (FD_ISSET(notifier->fd(), &read_fds))
|
||||
type |= NotificationType::Read;
|
||||
if (FD_ISSET(notifier->fd(), &write_fds))
|
||||
type |= NotificationType::Write;
|
||||
type &= notifier->type();
|
||||
if (type != NotificationType::None)
|
||||
ThreadEventQueue::current().post_event(*notifier, make<NotifierActivationEvent>(notifier->fd(), type));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue