[racket-dev] gui responsiveness

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Thu Apr 17 02:55:33 EDT 2014

Matthew Flatt wrote at 04/16/2014 01:56 PM:
>   (set! needed? #t)
>   (queue-callback (lambda () (when needed?
>                                (set! needed? #f)
>                                (send this refresh)))
>                   #f) ; => low priority

This is what I'd try first.  If it works well for your app, there are 
also micro-optimizations you could try atop it (e.g., if event queue is 
empty, do "send refresh" without "queue-callback"; and put a big "or" 
around it all, to not do anything if "needed?" is true, which I'm 
guessing shouldn't present a malignant race condition if you always 
clear the flag immediately before "send refresh").

If that doesn't work well enough for your app, you could try to get 
fancy with prioritizing events (perhaps by moving events off into 
secondary queues, or shoving events back onto the head of the main 
queue), but that could become hard to reason about and debug.

Neil V.

Posted on the dev mailing list.