(use data.queue) | |
(use gauche.partcont) | |
(define queue (make-queue)) | |
(define (make-worker) | |
(make-thread (lambda () | |
(while (dequeue! queue #f) | |
=> next | |
(print "==> call next") | |
(dynamic-wind | |
(lambda () | |
(print "start")) | |
(lambda () | |
(reset | |
(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