From 8561328213a02c552b6396e519aa9dbf1e75b171 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Fri, 10 Apr 2015 19:04:21 -0400 Subject: [PATCH] dont starve events when gui active --- chaos/gui.rkt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/chaos/gui.rkt b/chaos/gui.rkt index 4f5bf0b..57fd6de 100644 --- a/chaos/gui.rkt +++ b/chaos/gui.rkt @@ -6,6 +6,10 @@ racket/async-channel lux/chaos) +;; Robby says that I could rework this to remove the event-ch by +;; having capturing the continuation, storing it, and then calling it +;; from within the callback once an event is ready. + (struct gui (event-ch drawer frame refresh!) #:methods gen:chaos [(define (chaos-yield c e) @@ -72,8 +76,14 @@ [style (cons 'no-autoclear (if gl-config '(gl) '()))])) + (define the-refresh-sema (make-semaphore 0)) (define (refresh!) - (send c refresh-now)) + (queue-callback + (λ () + (send c refresh-now) + (semaphore-post the-refresh-sema)) + #f) + (yield the-refresh-sema)) (send f center) (send f show #t)