Ladybird+MacVideoPlayer: Align post_event with other event loop impls

After cherry-picking ladybird deferred invoke changes, the macOS event
loop implementations' post_event have diverged from everyone else's.

It tries to post the 'deferred invoke' event, but after all the changes
to how deferred invoke is dispatched, deferred invoke will never go
through post_event.

Restore the previous "wake if not my thread" behavior, and clean up the
unused atomic variable.
This commit is contained in:
Andrew Kaster authored and Andrew Kaster committed 2026-06-29 10:07:38 -04:00
1 parent 1d3f09aaec
commit 49557c2e12
2 files changed
+4 -10

No files matched your search

@@ -210,7 +210,6 @@ struct CFEventLoopImplementation::Impl {
context.info = &event_loop_implementation; context.info = &event_loop_implementation;
context.perform = [](void* info) { context.perform = [](void* info) {
auto& self = *static_cast<CFEventLoopImplementation*>(info); auto& self = *static_cast<CFEventLoopImplementation*>(info);
self.m_impl->deferred_source_pending = false;
self.m_thread_event_queue.process(); self.m_thread_event_queue.process();
}; };
@@ -226,7 +225,6 @@ struct CFEventLoopImplementation::Impl {
CFRunLoopRef run_loop { nullptr }; CFRunLoopRef run_loop { nullptr };
CFRunLoopSourceRef deferred_source { nullptr }; CFRunLoopSourceRef deferred_source { nullptr };
Atomic<bool> deferred_source_pending { false };
}; };
CFEventLoopImplementation::CFEventLoopImplementation() CFEventLoopImplementation::CFEventLoopImplementation()
@@ -450,9 +448,8 @@ void CFEventLoopImplementation::post_event(Core::EventReceiver* receiver, Nonnul
{ {
m_thread_event_queue.post_event(receiver, move(event)); m_thread_event_queue.post_event(receiver, move(event));
bool expected = false; if (&m_thread_event_queue != &Core::ThreadEventQueue::current())
if (m_impl->deferred_source && m_impl->deferred_source_pending.compare_exchange_strong(expected, true)) wake();
CFRunLoopSourceSignal(m_impl->deferred_source);
} }
} }
@@ -211,7 +211,6 @@ struct CFEventLoopImplementation::Impl {
context.info = &event_loop_implementation; context.info = &event_loop_implementation;
context.perform = [](void* info) { context.perform = [](void* info) {
auto& self = *static_cast<CFEventLoopImplementation*>(info); auto& self = *static_cast<CFEventLoopImplementation*>(info);
self.m_impl->deferred_source_pending = false;
self.m_thread_event_queue.process(); self.m_thread_event_queue.process();
}; };
@@ -227,7 +226,6 @@ struct CFEventLoopImplementation::Impl {
CFRunLoopRef run_loop { nullptr }; CFRunLoopRef run_loop { nullptr };
CFRunLoopSourceRef deferred_source { nullptr }; CFRunLoopSourceRef deferred_source { nullptr };
Atomic<bool> deferred_source_pending { false };
}; };
CFEventLoopImplementation::CFEventLoopImplementation() CFEventLoopImplementation::CFEventLoopImplementation()
@@ -451,9 +449,8 @@ void CFEventLoopImplementation::post_event(Core::EventReceiver* receiver, Nonnul
{ {
m_thread_event_queue.post_event(receiver, move(event)); m_thread_event_queue.post_event(receiver, move(event));
bool expected = false; if (&m_thread_event_queue != &Core::ThreadEventQueue::current())
if (m_impl->deferred_source && m_impl->deferred_source_pending.compare_exchange_strong(expected, true)) wake();
CFRunLoopSourceSignal(m_impl->deferred_source);
} }
} }