diff -u trunk/srfi-18.scm event-handlers/srfi-18.scm --- trunk/srfi-18.scm Tue Aug 6 22:54:02 2019 +++ event-handlers/srfi-18.scm Thu Jul 6 21:18:35 2023 @@ -522,4 +522,25 @@ (thread-yield!) ) +;;; hooks for suspending/resuming threads on event-queues +; (used for finalizers and signals) + +(define (##sys#resume-thread-on-event thread) + (when (eq? (##sys#slot thread 3) 'suspended) + (##sys#setslot thread 3 'ready) + (##sys#add-to-ready-queue thread) ) ) + +(define (##sys#suspend-thread-on-event thread) + (if (eq? thread ##sys#current-thread) + (if (and (null? (##sys#ready-queue)) + (null? (##sys#timeout-queue)) + (null? (##sys#fd-queue))) + (##sys#sleep-until-interrupt) ; wait until signal handler fires + (##sys#call-with-current-continuation + (lambda (return) + (##sys#setslot thread 3 'suspended) + (##sys#setslot thread 1 (lambda () (return (##core#undefined)))) + (##sys#schedule) ) ) ) + (##sys#setslot thread 3 'suspended))) + ) Common subdirectories: trunk/tests and event-handlers/tests