From efca84e8b5204c4d5ce28113474df0bf0b67dbf3 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 16:55:45 +0300 Subject: Wake and post to loops from any thread, and watch signals wsap_term runs its own eventfds to wake the loop from its pty worker and accessibility threads, and its own signalfd or self-pipe per platform. yasl_loop_kick() is now documented as safe from any thread and from a signal handler. yasl_loop_post() queues a function to run on the owning thread during a later step. yasl_loop_watch_signals() installs a process-wide SA_RESTART handler per signal that records the signal and kicks the loop, so callbacks run on the loop thread on every platform without touching thread masks. Cocoa dispatch waited only for AppKit events, so kicks, posts, and fd watches could not end an indefinite wait, and yasl_post_event() did not wake yasl_run(). While waiting, Cocoa now mirrors the loop's descriptors in a kqueue whose run loop source posts a wake event. If kqueue rejects a descriptor, the wait is bounded to 10 ms. The Cocoa change is not built or run here; it needs a macOS check. Co-Authored-By: Claude Opus 5.5 --- include/yasl/app.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/yasl/app.h') diff --git a/include/yasl/app.h b/include/yasl/app.h index bf6de9c..b7e1c13 100644 --- a/include/yasl/app.h +++ b/include/yasl/app.h @@ -98,7 +98,8 @@ YASL_API void yasl_surface_request_frame(struct yasl_surface *s); * @param code Application-defined message code (yasl_user_event.code). * @param payload Arbitrary pointer passed through to the event. * @param size Optional payload size. - * @return true if queued successfully, false if queue is full or memory failed. + * @return true if queued; false if memory failed or d is not run by yasl_run(). + * Applications that run their own loop use yasl_loop_post() instead. */ YASL_API bool yasl_post_event(struct yasl_display *d, struct yasl_surface *s, uint32_t code, void *payload, size_t size); -- cgit v1.2.3