mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-02 04:40:29 +02:00
* threads.scm (parallel, letpar): Rewritten.
This commit is contained in:
parent
361d631fb7
commit
c2950e36ef
2 changed files with 18 additions and 8 deletions
|
@ -1,3 +1,7 @@
|
|||
2003-01-24 Mikael Djurfeldt <djurfeldt@nada.kth.se>
|
||||
|
||||
* threads.scm (parallel, letpar): Rewritten.
|
||||
|
||||
2003-01-23 Mikael Djurfeldt <djurfeldt@nada.kth.se>
|
||||
|
||||
* threads.scm (par-mapper, n-par-map, n-par-for-each): Use
|
||||
|
|
|
@ -165,16 +165,22 @@
|
|||
(cond ((null? forms) '(begin))
|
||||
((null? (cdr forms)) (car forms))
|
||||
(else
|
||||
`(apply values
|
||||
(map future-ref
|
||||
(list ,@(map (lambda (form) `(future ,form)) forms)))))))
|
||||
(let ((vars (map (lambda (f)
|
||||
(make-symbol "f"))
|
||||
forms)))
|
||||
`((lambda ,vars
|
||||
(values ,@(map (lambda (v) `(future-ref ,v)) vars)))
|
||||
,@(map (lambda (form) `(future ,form)) forms))))))
|
||||
|
||||
(define-macro (letpar bindings . body)
|
||||
`(call-with-values
|
||||
(lambda ()
|
||||
(parallel ,@(map cadr bindings)))
|
||||
(lambda ,(map car bindings)
|
||||
,@body)))
|
||||
(cond ((or (null? bindings) (null? (cdr bindings)))
|
||||
`(let ,bindings ,@body))
|
||||
(else
|
||||
(let ((vars (map car bindings)))
|
||||
`((lambda ,vars
|
||||
((lambda ,vars ,@body)
|
||||
,@(map (lambda (v) `(future-ref ,v)) vars)))
|
||||
,@(map (lambda (b) `(future ,(cadr b))) bindings))))))
|
||||
|
||||
(define-macro (make-thread proc . args)
|
||||
`(call-with-new-thread
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue