[racket] Future thread

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Apr 18 15:44:05 EDT 2011

I have a program that spends most of the time waiting for user
input/time to advance (think of a World.) I have a computation that I
can perform at Frame 0, but I don't need the result until Frame 10. I
will do some work between these frames.

I'd like to be able to have this computation take place in the
background in parallel. I'd create it in frame 0, but delay forcing it
until frame 10.

Now, if I used a future, then, if the future does something unsafe,
let's say half way through its execution, then half of the work would
be blocked until frame 10. So, 50% of the task would be in parallel.

If I used a thread, then nothing would run in parallel, but it would
run in the background---i.e. utilize the time in between my frames.
But this would actually compete with the work for frames 1 through 9,
so they'd run slower.

I'd like the best of both worlds. I would imagine that this would work
by having blocked futures be a schedule-able thread so that if they
need to do unsafe work---and no other Racket thread is
available---then they could be selected for a quanta before being put
back in the truly parallel world.

Do futures already work like this? The documentation seems to suggest
not. If not, is this possible?

Jay

-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.