(done-tick 0)
(next-secondary-tick secondary-gc-rate))
(let glib-thread-loop ()
+ (if (not (eq? interrupt-mask/all
+ ((ucode-primitive get-interrupt-enables 0))))
+ (outf-error "\nglib-thread-loop: already running without-interrupts\n"))
(without-interrupts
(lambda ()
(let ((gc-tick (car (gc-timestamp))))
(if (fix:< next-secondary-tick gc-tick)
(begin
(%trace ";run-glib secondary-gc daemons\n")
- (trigger-secondary-gc-daemons!)
+ (run-glib-daemons)
(%trace ";run-glib secondary-gc daemons done\n")
(set! next-secondary-tick
(fix:+ gc-tick secondary-gc-rate)))))))
(loop (cdr alist) alist)
(let ((thunk (weak-cdr (car alist)))
(next (cdr alist)))
- (thunk)
+ (with-glib-error-handler "this GLib cleanup" thunk)
(if prev
(set-cdr! prev next)
(set! glib-cleanups next))
(loop next prev))))))
+(define (run-glib-daemons)
+ (with-glib-error-handler "the secondary GC daemons"
+ trigger-secondary-gc-daemons!))
+
+(define (with-glib-error-handler what thunk)
+ (call-with-current-continuation
+ (lambda (continue)
+ ;;(with-restart name reporter effector interactor thunk)
+ (with-restart 'ABORT
+ (string-append "Punt "what"; return to the GLib main loop.")
+ (named-lambda (glib-abort-effector . args)
+ (declare (ignore args))
+ (continue unspecific))
+ (named-lambda (glib-abort-interactor . args)
+ (apply values args))
+ thunk))))
+
(define (reset-glib-cleanups!)
(set! glib-cleanups '()))