-
-
Save nkoguro/bcb23f9a1913cfced2817680d3fcfb46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use data.queue) | |
(use gauche.partcont) | |
(define queue (make-queue)) | |
(define (make-worker) | |
(make-thread (lambda () | |
(while (dequeue! queue #f) | |
=> next | |
(print "==> call next") | |
(reset | |
(dynamic-wind | |
(lambda () | |
(print "start")) | |
next | |
(lambda () | |
(print "end")))))))) | |
(define (yield) | |
(shift cont | |
(enqueue! queue cont))) | |
(define (main args) | |
(enqueue! queue (lambda () | |
(guard (e (else (print "catch error!!"))) | |
(yield) | |
(error "err")))) | |
(while (dequeue! queue #f) | |
=> next | |
(print "==> call next") | |
(reset | |
(dynamic-wind | |
(lambda () | |
(print "start")) | |
next | |
(lambda () | |
(print "end"))))) | |
0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment