Skip to content

Instantly share code, notes, and snippets.

@karahiyo
Created June 27, 2017 01:23
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 karahiyo/50e32bf5387ec1303c745a87469f1b23 to your computer and use it in GitHub Desktop.
Save karahiyo/50e32bf5387ec1303c745a87469f1b23 to your computer and use it in GitHub Desktop.
gauche thread-pool test
#!/usr/bin/env gosh
(use control.thread-pool)
(define (log msg)
(print (sys-time) ": " msg))
(log "start")
(define (run ls)
(let* ((pool (make-thread-pool 5)))
(begin
(map (^n (add-job! pool
(lambda()
(begin
(log (list "at" n))
(sys-sleep 1)
))))
ls)
(wait-all pool))))
(run '(1 2 3 4 5 6 7 8 9))
(log "finish")
@karahiyo
Copy link
Author

$ gosh thread-pool-test.scm                                                        
1498526536: start
1498526536: (at 1)
1498526536: (at 3)
1498526536: (at 2)
1498526536: (at 4)
1498526536: (at 5)
1498526537: (at 6)
1498526537: (at 7)
1498526537: (at 9)
1498526537: (at 8)
1498526538: finish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment