1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

futures: Support multiple-value returns.

* module/ice-9/futures.scm (process-future!): Use `call-with-values'
  when invoking `(future-thunk future)'.

* test-suite/tests/future.test ("futures")["multiple values"]: New test.
This commit is contained in:
Ludovic Courtès 2010-12-16 17:38:32 +01:00
parent 691a1c3c06
commit 6c17f7bd71
2 changed files with 13 additions and 3 deletions

View file

@ -83,9 +83,10 @@ touched."
(set-future-result! future (set-future-result! future
(catch #t (catch #t
(lambda () (lambda ()
(let ((result ((future-thunk future)))) (call-with-values (future-thunk future)
(lambda () (lambda results
result))) (lambda ()
(apply values results)))))
(lambda args (lambda args
(lambda () (lambda ()
(apply throw args))))) (apply throw args)))))

View file

@ -75,6 +75,15 @@
(iota 123))))))) (iota 123)))))))
(reduce + 0 (iota 123)))) (reduce + 0 (iota 123))))
(pass-if "multiple values"
(let ((lst (iota 123)))
(equal? (zip lst lst)
(map (lambda (f)
(call-with-values (cut touch f) list))
(map (lambda (i)
(future (values i i)))
lst)))))
(pass-if "no exception" (pass-if "no exception"
(future? (future (throw 'foo 'bar)))) (future? (future (throw 'foo 'bar))))