[plt-scheme] Implementing engines using threads

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Wed Apr 28 12:20:06 EDT 2004

Matthew Flatt wrote:

> At Tue, 27 Apr 2004 23:39:14 +0200, Jens Axel Søgaard wrote:

>>but it goes with out saying that a continuation captured in one thread
>>can not be reified in another.

> ... unless you use version 299.2 or later (which has other problems,
> for now).

Interesting news.

>>Is there an elegant way to communicate the return value of success to
>>the caller of the engine?

> I think you'll have to use `set!':
>  (define (make-engine a-thunk)
>    (lambda (ticks success failure)
>      (let ([result #f])
>        (let ([work-thread (thread (lambda () (set! result (a-thunk))))])

Ah yes. Using call/cc here is like shooting pigeons with a cannon.

Jens Axel Søgaard

Posted on the users mailing list.