[bitc-dev] BitC, Irken, CPS
Sam Rushing
sam-bitc at rushing.nightmare.com
Fri Feb 6 21:42:02 EST 2009
Sandro Magi wrote:
> He means asymmetric coroutines, such as what Python and C# support. See
> Microsoft's "Concurrency and Coordination Runtime" for an example of
> using generators to implement a lightweight concurrency framework.
>
>
http://en.wikipedia.org/wiki/Generator_(computer_science)
Here's the implementation I'm using in Irken:
;; based on:
;; http://www.cs.brown.edu/pipermail/plt-scheme/2006-April/012418.html
(define (make-generator producer)
(let ((ready #f)
;; just holding useless continuations
(caller (call/cc id))
(saved-point (call/cc id)))
(define (entry-point)
(call/cc
(lambda (k)
(set! caller k)
(if ready
(saved-point #f)
(producer yield)))))
(define (yield v)
(call/cc
(lambda (k)
(set! ready #t)
(set! saved-point k)
(caller v))))
entry-point
))
-Sam
More information about the bitc-dev
mailing list