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

_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to