LibCore: Add thread-safe weak deferred_invoke()

Add a thread-safe deferred_invoke() API on WeakEventLoopReference that
queues work onto the owning thread's event queue and wakes that thread
via EventLoopManager hooks. This avoids calling wake() from foreign
threads during teardown.

Implement current_thread_handle()/wake_thread() in each backend and
track per-thread data so handles are validated before waking:

- Unix: wake via per-thread wake pipe
- Windows: wake via thread wake event
- macOS: wake via stored CFRunLoopRef
- Qt: wake via event target or QEventLoop::wakeUp()
- Android: wake via stored ALooper
This commit is contained in:
Andreas Kling
2026-01-23 17:16:40 +01:00
committed by Andreas Kling
parent 367296fce6
commit 96ce468b60
Notes: github-actions[bot] 2026-02-06 11:08:22 +00:00
13 changed files with 220 additions and 0 deletions

View File

@@ -25,6 +25,8 @@ public:
virtual void unregister_notifier(Notifier&) override;
virtual void did_post_event() override;
virtual EventLoopThreadHandle current_thread_handle() override;
virtual void wake_thread(EventLoopThreadHandle) override;
virtual int register_signal(int signal_number, Function<void(int)> handler) override;
virtual void unregister_signal(int handler_id) override;