Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibCore+WebWorker: EventLoop-related cleanups #3145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions Libraries/LibCore/EventLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ void EventLoop::quit(int code)
m_impl->quit(code);
}

void EventLoop::unquit()
{
m_impl->unquit();
}

struct EventLoopPusher {
public:
EventLoopPusher(EventLoop& event_loop)
Expand All @@ -91,7 +86,7 @@ int EventLoop::exec()
void EventLoop::spin_until(Function<bool()> goal_condition)
{
EventLoopPusher pusher(*this);
while (!m_impl->was_exit_requested() && !goal_condition())
while (!goal_condition())
pump();
}

Expand Down Expand Up @@ -120,11 +115,6 @@ void EventLoop::unregister_signal(int handler_id)
EventLoopManager::the().unregister_signal(handler_id);
}

void EventLoop::notify_forked(ForkEvent)
{
current().m_impl->notify_forked_and_in_child();
}

intptr_t EventLoop::register_timer(EventReceiver& object, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible fire_when_not_visible)
{
return EventLoopManager::the().register_timer(object, milliseconds, should_reload, fire_when_not_visible);
Expand Down Expand Up @@ -161,9 +151,4 @@ void deferred_invoke(Function<void()> invokee)
EventLoop::current().deferred_invoke(move(invokee));
}

bool EventLoop::was_exit_requested() const
{
return m_impl->was_exit_requested();
}

}
9 changes: 0 additions & 9 deletions Libraries/LibCore/EventLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class EventLoop {
void wake();

void quit(int);
void unquit();
bool was_exit_requested() const;

// The registration functions act upon the current loop of the current thread.
static intptr_t register_timer(EventReceiver&, int milliseconds, bool should_reload, TimerShouldFireWhenNotVisible);
Expand All @@ -85,13 +83,6 @@ class EventLoop {
static int register_signal(int signo, ESCAPING Function<void(int)> handler);
static void unregister_signal(int handler_id);

// Note: Boost uses Parent/Child/Prepare, but we don't really have anything
// interesting to do in the parent or before forking.
enum class ForkEvent {
Child,
};
static void notify_forked(ForkEvent);

static bool is_running();
static EventLoop& current();

Expand Down
5 changes: 0 additions & 5 deletions Libraries/LibCore/EventLoopImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class EventLoopImplementation {

virtual void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&) = 0;

// FIXME: These APIs only exist for obscure use-cases inside SerenityOS. Try to get rid of them.
virtual void unquit() = 0;
virtual bool was_exit_requested() const = 0;
virtual void notify_forked_and_in_child() = 0;

protected:
EventLoopImplementation();
ThreadEventQueue& m_thread_event_queue;
Expand Down
26 changes: 0 additions & 26 deletions Libraries/LibCore/EventLoopImplementationUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,6 @@ void EventLoopImplementationUnix::quit(int code)
m_exit_code = code;
}

void EventLoopImplementationUnix::unquit()
{
m_exit_requested = false;
m_exit_code = 0;
}

bool EventLoopImplementationUnix::was_exit_requested() const
{
return m_exit_requested;
}

void EventLoopImplementationUnix::post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&& event)
{
m_thread_event_queue.post_event(receiver, move(event));
Expand Down Expand Up @@ -522,21 +511,6 @@ void EventLoopManagerUnix::dispatch_signal(int signal_number)
}
}

void EventLoopImplementationUnix::notify_forked_and_in_child()
{
auto& thread_data = ThreadData::the();
thread_data.timeouts.clear();
thread_data.poll_fds.clear();
thread_data.notifier_by_ptr.clear();
thread_data.notifier_by_index.clear();
thread_data.initialize_wake_pipe();
if (auto* info = signals_info<false>()) {
info->signal_handlers.clear();
info->next_signal_id = 0;
}
thread_data.pid = getpid();
}

SignalHandlers::SignalHandlers(int signal_number, void (*handle_signal)(int))
: m_signal_number(signal_number)
, m_original_handler(signal(signal_number, handle_signal))
Expand Down
3 changes: 0 additions & 3 deletions Libraries/LibCore/EventLoopImplementationUnix.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class EventLoopImplementationUnix final : public EventLoopImplementation {

virtual void wake() override;

virtual void unquit() override;
virtual bool was_exit_requested() const override;
virtual void notify_forked_and_in_child() override;
virtual void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&) override;

private:
Expand Down
17 changes: 0 additions & 17 deletions Libraries/LibCore/EventLoopImplementationWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,6 @@ void EventLoopImplementationWindows::quit(int code)
m_exit_code = code;
}

void EventLoopImplementationWindows::unquit()
{
m_exit_requested = false;
m_exit_code = 0;
}

bool EventLoopImplementationWindows::was_exit_requested() const
{
return m_exit_requested;
}

void EventLoopImplementationWindows::post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&& event)
{
m_thread_event_queue.post_event(receiver, move(event));
Expand All @@ -157,12 +146,6 @@ void EventLoopImplementationWindows::wake()
SetEvent(m_wake_event);
}

void EventLoopImplementationWindows::notify_forked_and_in_child()
{
dbgln("Core::EventLoopManagerWindows::notify_forked_and_in_child() is not implemented");
VERIFY_NOT_REACHED();
}

static int notifier_type_to_network_event(NotificationType type)
{
switch (type) {
Expand Down
3 changes: 0 additions & 3 deletions Libraries/LibCore/EventLoopImplementationWindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ class EventLoopImplementationWindows final : public EventLoopImplementation {

virtual void wake() override;

virtual void unquit() override;
virtual bool was_exit_requested() const override;
virtual void notify_forked_and_in_child() override;
virtual void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&) override;

private:
Expand Down
5 changes: 0 additions & 5 deletions Libraries/LibWebView/EventLoop/EventLoopImplementationMacOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ class EventLoopImplementationMacOS final : public Core::EventLoopImplementation
virtual void wake() override;
virtual void post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&&) override;

// FIXME: These APIs only exist for obscure use-cases inside SerenityOS. Try to get rid of them.
virtual void unquit() override { }
virtual bool was_exit_requested() const override { return false; }
virtual void notify_forked_and_in_child() override { }

private:
EventLoopImplementationMacOS() = default;

Expand Down
5 changes: 0 additions & 5 deletions Libraries/LibWebView/EventLoop/EventLoopImplementationQt.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ class EventLoopImplementationQt final : public Core::EventLoopImplementation {
virtual void wake() override;
virtual void post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&&) override;

// FIXME: These APIs only exist for obscure use-cases inside SerenityOS. Try to get rid of them.
virtual void unquit() override { }
virtual bool was_exit_requested() const override { return false; }
virtual void notify_forked_and_in_child() override { }

void set_main_loop();

private:
Expand Down
9 changes: 0 additions & 9 deletions Services/WebWorker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
#include <LibWebView/Utilities.h>
#include <WebWorker/ConnectionFromClient.h>

#if defined(HAVE_QT)
# include <LibWebView/EventLoop/EventLoopImplementationQt.h>
# include <QCoreApplication>
#endif

static ErrorOr<void> initialize_resource_loader(GC::Heap&, int request_server_socket);

ErrorOr<int> serenity_main(Main::Arguments arguments)
Expand All @@ -50,10 +45,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (wait_for_debugger)
Core::Process::wait_for_debugger_and_break();

#if defined(HAVE_QT)
QCoreApplication app(arguments.argc, arguments.argv);
Core::EventLoopManager::install(*new WebView::EventLoopManagerQt);
#endif
Core::EventLoop event_loop;

WebView::platform_init();
Expand Down
Loading