From d1cea5724617203750d3149f68acf2beadb13159 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 25 Jan 2022 08:54:54 +0100 Subject: [PATCH] LibThreading: Invoke BackgroundAction completions on origin event loop We now capture the origin thread's current event loop when setting up a BackgroundAction and then invoke the on_complete callback on that same event loop. --- Userland/Libraries/LibThreading/BackgroundAction.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibThreading/BackgroundAction.h b/Userland/Libraries/LibThreading/BackgroundAction.h index 64d9338cc9..39d2bf5f4b 100644 --- a/Userland/Libraries/LibThreading/BackgroundAction.h +++ b/Userland/Libraries/LibThreading/BackgroundAction.h @@ -56,10 +56,10 @@ private: , m_action(move(action)) , m_on_complete(move(on_complete)) { - enqueue_work([this] { + enqueue_work([this, origin_event_loop = &Core::EventLoop::current()] { m_result = m_action(*this); if (m_on_complete) { - deferred_invoke([this] { + origin_event_loop->deferred_invoke([this] { m_on_complete(m_result.release_value()); remove_from_parent(); });