-
-
Save nkoguro/0ca865b06c1a06d33f32f93e5861a980 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 (wrap thunk) | |
(lambda () | |
(reset | |
(thunk)))) | |
(define (yield) | |
(shift cont | |
(enqueue! queue (wrap cont)))) | |
(define (main args) | |
(enqueue! queue (wrap (lambda () | |
(let1 counter 0 | |
(while #t | |
(inc! counter) | |
(when (= counter 100000) | |
(set! counter 0) | |
(format #t "~s~%" (gc-stat))) | |
(yield)))))) | |
(while #t | |
(let1 next (dequeue! queue #f) | |
(when next | |
(next)))) | |
0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment