mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-05 01:10:24 +00:00
LibCore: Remove ability to post heap-allocated Core::Event objects
We no longer need this API since all clients have been converted to simply posting the Core::Event::Type (or a callback function).
This commit is contained in:
committed by
Andreas Kling
parent
2a1c5dc108
commit
cebc4d00dd
Notes:
github-actions[bot]
2025-12-03 12:27:38 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/cebc4d00ddf Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7004
@@ -102,11 +102,6 @@ size_t EventLoop::pump(WaitMode mode)
|
||||
return m_impl->pump(mode == WaitMode::WaitForEvents ? EventLoopImplementation::PumpMode::WaitForEvents : EventLoopImplementation::PumpMode::DontWaitForEvents);
|
||||
}
|
||||
|
||||
void EventLoop::post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&& event)
|
||||
{
|
||||
m_impl->post_event(&receiver, move(event));
|
||||
}
|
||||
|
||||
void EventLoop::add_job(NonnullRefPtr<Promise<NonnullRefPtr<EventReceiver>>> job_promise)
|
||||
{
|
||||
ThreadEventQueue::current().add_job(move(job_promise));
|
||||
|
||||
@@ -67,9 +67,6 @@ public:
|
||||
// Pump the event loop until some condition is met.
|
||||
void spin_until(Function<bool()>);
|
||||
|
||||
// Post an event to this event loop.
|
||||
void post_event(EventReceiver& receiver, NonnullOwnPtr<Event>&&);
|
||||
|
||||
void add_job(NonnullRefPtr<Promise<NonnullRefPtr<EventReceiver>>> job_promise);
|
||||
|
||||
void deferred_invoke(ESCAPING Function<void()>);
|
||||
|
||||
@@ -54,8 +54,6 @@ public:
|
||||
virtual void wake() = 0;
|
||||
virtual bool was_exit_requested() const = 0;
|
||||
|
||||
virtual void post_event(EventReceiver*, NonnullOwnPtr<Event>&&) = 0;
|
||||
|
||||
virtual void deferred_invoke(Function<void()>&&);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -314,13 +314,6 @@ void EventLoopImplementationUnix::quit(int code)
|
||||
m_exit_code = code;
|
||||
}
|
||||
|
||||
void EventLoopImplementationUnix::post_event(EventReceiver* receiver, NonnullOwnPtr<Event>&& event)
|
||||
{
|
||||
m_thread_event_queue.post_event(receiver, move(event));
|
||||
if (&m_thread_event_queue != &ThreadEventQueue::current())
|
||||
wake();
|
||||
}
|
||||
|
||||
void EventLoopImplementationUnix::wake()
|
||||
{
|
||||
int wake_event = 0;
|
||||
|
||||
@@ -51,8 +51,6 @@ public:
|
||||
|
||||
virtual void wake() override;
|
||||
|
||||
virtual void post_event(EventReceiver*, NonnullOwnPtr<Event>&&) override;
|
||||
|
||||
private:
|
||||
bool m_exit_requested { false };
|
||||
int m_exit_code { 0 };
|
||||
|
||||
@@ -232,13 +232,6 @@ void EventLoopImplementationWindows::quit(int code)
|
||||
m_exit_code = code;
|
||||
}
|
||||
|
||||
void EventLoopImplementationWindows::post_event(EventReceiver* receiver, NonnullOwnPtr<Event>&& event)
|
||||
{
|
||||
m_thread_event_queue.post_event(receiver, move(event));
|
||||
if (&m_thread_event_queue != &ThreadEventQueue::current())
|
||||
wake();
|
||||
}
|
||||
|
||||
void EventLoopImplementationWindows::wake()
|
||||
{
|
||||
SetEvent(m_wake_event);
|
||||
|
||||
@@ -42,8 +42,6 @@ public:
|
||||
virtual void wake() override;
|
||||
virtual bool was_exit_requested() const override { return m_exit_requested; }
|
||||
|
||||
virtual void post_event(EventReceiver*, NonnullOwnPtr<Event>&&) override;
|
||||
|
||||
private:
|
||||
bool m_exit_requested { false };
|
||||
int m_exit_code { 0 };
|
||||
|
||||
@@ -21,13 +21,6 @@ struct ThreadEventQueue::Private {
|
||||
AK_MAKE_DEFAULT_MOVABLE(QueuedEvent);
|
||||
|
||||
public:
|
||||
QueuedEvent(RefPtr<EventReceiver> const& receiver, NonnullOwnPtr<Event> event)
|
||||
: receiver(receiver)
|
||||
, event(move(event))
|
||||
, event_type(this->event->type())
|
||||
{
|
||||
}
|
||||
|
||||
QueuedEvent(RefPtr<EventReceiver> const& receiver, Event::Type event_type)
|
||||
: receiver(receiver)
|
||||
, event_type(event_type)
|
||||
@@ -43,7 +36,6 @@ struct ThreadEventQueue::Private {
|
||||
~QueuedEvent() = default;
|
||||
|
||||
WeakPtr<EventReceiver> receiver;
|
||||
OwnPtr<Event> event;
|
||||
Function<void()> m_invokee;
|
||||
u8 event_type { Event::Type::Invalid };
|
||||
};
|
||||
@@ -81,15 +73,6 @@ ThreadEventQueue::ThreadEventQueue()
|
||||
|
||||
ThreadEventQueue::~ThreadEventQueue() = default;
|
||||
|
||||
void ThreadEventQueue::post_event(Core::EventReceiver* receiver, NonnullOwnPtr<Core::Event> event)
|
||||
{
|
||||
{
|
||||
Threading::MutexLocker lock(m_private->mutex);
|
||||
m_private->queued_events.empend(receiver, move(event));
|
||||
}
|
||||
Core::EventLoopManager::the().did_post_event();
|
||||
}
|
||||
|
||||
void ThreadEventQueue::post_event(Core::EventReceiver* receiver, Core::Event::Type event_type)
|
||||
{
|
||||
{
|
||||
@@ -147,8 +130,7 @@ size_t ThreadEventQueue::process()
|
||||
break;
|
||||
}
|
||||
default:
|
||||
receiver->dispatch_event(*queued_event.event);
|
||||
break;
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
} else {
|
||||
if (queued_event.event_type == Event::Type::DeferredInvoke) {
|
||||
|
||||
@@ -26,7 +26,6 @@ public:
|
||||
size_t process();
|
||||
|
||||
// Posts an event to the event queue.
|
||||
void post_event(EventReceiver*, NonnullOwnPtr<Event>);
|
||||
void post_event(EventReceiver*, Core::Event::Type);
|
||||
|
||||
// Post a deferred invocation to the event queue.
|
||||
|
||||
@@ -41,7 +41,6 @@ public:
|
||||
virtual void quit(int) override;
|
||||
virtual void wake() override;
|
||||
virtual bool was_exit_requested() const override;
|
||||
virtual void post_event(Core::EventReceiver*, NonnullOwnPtr<Core::Event>&&) override;
|
||||
|
||||
virtual ~EventLoopImplementationMacOS() override;
|
||||
|
||||
|
||||
@@ -485,14 +485,4 @@ bool EventLoopImplementationMacOS::was_exit_requested() const
|
||||
return ![NSApp isRunning];
|
||||
}
|
||||
|
||||
void EventLoopImplementationMacOS::post_event(Core::EventReceiver* receiver, NonnullOwnPtr<Core::Event>&& event)
|
||||
{
|
||||
m_thread_event_queue.post_event(receiver, move(event));
|
||||
|
||||
bool expected = false;
|
||||
if (m_impl->deferred_source && m_impl->deferred_source_pending.compare_exchange_strong(expected, true)) {
|
||||
CFRunLoopSourceSignal(m_impl->deferred_source);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -252,13 +252,6 @@ bool EventLoopImplementationQt::was_exit_requested() const
|
||||
return !m_event_loop->isRunning();
|
||||
}
|
||||
|
||||
void EventLoopImplementationQt::post_event(Core::EventReceiver* receiver, NonnullOwnPtr<Core::Event>&& event)
|
||||
{
|
||||
m_thread_event_queue.post_event(receiver, move(event));
|
||||
if (&m_thread_event_queue != &Core::ThreadEventQueue::current())
|
||||
wake();
|
||||
}
|
||||
|
||||
void EventLoopImplementationQt::set_main_loop()
|
||||
{
|
||||
m_main_loop = true;
|
||||
|
||||
@@ -59,8 +59,6 @@ public:
|
||||
virtual void wake() override;
|
||||
virtual bool was_exit_requested() const override;
|
||||
|
||||
virtual void post_event(Core::EventReceiver*, NonnullOwnPtr<Core::Event>&&) override;
|
||||
|
||||
void set_main_loop();
|
||||
|
||||
private:
|
||||
|
||||
@@ -69,7 +69,6 @@ public:
|
||||
virtual size_t pump(PumpMode) override;
|
||||
virtual void quit(int) override;
|
||||
virtual void wake() override;
|
||||
virtual void post_event(Core::EventReceiver& receiver, NonnullOwnPtr<Core::Event>&&) override;
|
||||
|
||||
virtual bool was_exit_requested() const override { return false; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user