fibers-experiments.scm 571 B

123456789101112131415161718192021222324
  1. (import (except (rnrs base) error)
  2. (only (guile)
  3. lambda* λ
  4. simple-format)
  5. ;; fibers
  6. (fibers)
  7. (fibers channels))
  8. (define call-with-channel-input-string
  9. (λ (string proc)
  10. (let ([chan (make-channel)])
  11. (spawn-fiber (λ () (proc chan)))
  12. (put-message chan string)
  13. (simple-format #t "wrote message to channel: ~a\n" string))))
  14. (run-fibers
  15. (λ ()
  16. (call-with-channel-input-string
  17. "Hello!"
  18. (λ (channel)
  19. (simple-format #t "received message: ~a\n" (get-message channel))))))