Someone
public text v1 · immutable(use util.queue)
(use control.thread-pool)
(use gauche.parameter)
(use srfi-27)
(use rfc.http)
(define *max-thread* (make-parameter 3))
(define (threaded-map proc lst)
(let1 pool (make-thread-pool (*max-thread*))
(for-each (^x (add-job! pool (cut proc x) #t)) lst)
(terminate-all! pool)
(map (cut ~ <> 'result) (queue->list (thread-pool-results pool)))
))
(define a
(threaded-map
(^x
(sys-sleep (random-integer 4))
(http-get "example.com" "/")
x)
'(1 2 3 4 5 6 7 8)))
(display a)