[racket] understanding future/touch

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Jan 25 12:03:58 EST 2011

On Tuesday, January 25, 2011, Eric Tanter <etanter at dcc.uchile.cl> wrote:
>>> In order to know if it does, and when, I added a write in the future computation.
>>> (let ([f (future (lambda () (write "ok") (any-double? l2)))])
>>>        (list (any-double? l1)
>>>              (touch f)))
>>> I am surprised that if I don't call touch, the future computation is never run (at least not in the many many tries I did).
>> How are you testing that it is not run?
> the call to (write "ok") above
>> If the future needs to do
>> something to the global VM state, then it will block and wait to
>> resume on the touch, but everything before that will still be done in
>> parallel.
> so with Jay's additional info, I infer that the future is indeed started in parallel as soon as it is defined, then reaches the (write "ok"), deemed unsafe, put to wait until the touch, if any.
> -- Éric
> PS: btw, this explanation answers the question of whether or not "the thunk is safe" is determined dynamically, step-by-step, not through an analysis of the code. Right?



>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.