Fix par-map&

To actually work in parallel.
This commit is contained in:
Christopher Baines 2024-01-18 14:40:48 +00:00
parent 46b4c87e92
commit b8bd56a8f5

View file

@ -479,16 +479,18 @@ available. Return the resource once PROC has returned."
(define (par-mapper' mapper cons)
(lambda (proc . lists)
(let loop ((lists lists))
(match lists
(((heads tails ...) ...)
(let ((tail (loop tails))
(head (defer-to-parallel-fiber
(lambda ()
(apply proc heads)))))
(cons (fetch-result-of-defered-thunks head) tail)))
(_
'())))))
(apply
fetch-result-of-defered-thunks
(let loop ((lists lists))
(match lists
(((heads tails ...) ...)
(let ((tail (loop tails))
(head (defer-to-parallel-fiber
(lambda ()
(apply proc heads)))))
(cons head tail)))
(_
'()))))))
(define par-map& (par-mapper' map cons))