Skip to content

Instantly share code, notes, and snippets.

@nkoguro
Created May 30, 2020 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkoguro/fee9551e6cfee0a633eb7991dd16df95 to your computer and use it in GitHub Desktop.
Save nkoguro/fee9551e6cfee0a633eb7991dd16df95 to your computer and use it in GitHub Desktop.
(use control.thread-pool)
(use gauche.partcont)
(use gauche.threads)
(define pool (make-thread-pool 1))
(define (wrap thunk)
(lambda ()
(reset
(thunk))))
(define (yield)
(shift cont
(add-job! pool (wrap cont))))
(define (main args)
(add-job! pool (wrap (lambda ()
(let1 counter 0
(while #t
(inc! counter)
(when (= counter 100000)
(set! counter 0)
(format #t "~s~%" (gc-stat)))
(yield))))))
(thread-sleep! 1000000000)
0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment