[racket] CPU-heavy operations and GUI responsiveness
On Apr 13, 2012, at 6:38 AM, Michael W wrote:
> Hey, Racketeers!
>
> So I have a program that does a bunch of expensive image
> processing, but I want it to interactively draw its results to a
> canvas% as it runs.
>
> Only problem is events: I also want it to, say, stop right when I
> close the window or furiously mash Esc, for example.
>
> I've found that the built-in GUI handler thread never gets around
> to processing the events while the scientific part of the program
> is running unless I do something like (sleep 0.1) every so often,
> which, if done too often, slows the program down of course. Even
> calling (yield) in my CPU-intensive routines doesn't seem to
> drain the GUI event queue (it seems to only be effective within
> event callbacks? is my understanding right?)
NB: I am *not* the expert here…
A tenth of a second is huge. What if you slept for 20ms every once in a while, instead?
Also, I bet you could test your assertion about yield by writing a small program that uses a "place" to feed events into a queue, and measures how long they take to get handled. That's probably less than 30 minutes of programming….
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4800 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20120413/10dcdfd1/attachment.p7s>