Drain multiple external ground events at once. (Good or bad idea?)

This commit is contained in:
Tony Garnock-Jones 2018-05-01 17:34:51 +01:00
parent 65b2c94161
commit 38c6bfd20e

View file

@ -40,14 +40,24 @@
(define ground-event-relay-actor #f)
(define background-activity-count 0)
(define (handle-ground-event-item item)
(match item
[(? procedure? proc)
(push-script! ground-event-relay-actor
(lambda () (proc ground-event-relay-actor)))]
[(? number? delta)
(set! background-activity-count (+ background-activity-count delta))]))
(define (drain-external-events)
(define item (async-channel-try-get ch))
(when item
(handle-ground-event-item item)
(drain-external-events)))
(define ground-event-relay-evt
(handle-evt ch (lambda (item)
(match item
[(? procedure? proc)
(push-script! ground-event-relay-actor
(lambda () (proc ground-event-relay-actor)))]
[(? number? delta)
(set! background-activity-count (+ background-activity-count delta))]))))
(handle-ground-event-item item)
(drain-external-events))))
(define ds (make-dataspace
(lambda ()