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:
parent
691a1c3c06
commit
6c17f7bd71
2 changed files with 13 additions and 3 deletions
|
@ -83,9 +83,10 @@ touched."
|
|||
(set-future-result! future
|
||||
(catch #t
|
||||
(lambda ()
|
||||
(let ((result ((future-thunk future))))
|
||||
(call-with-values (future-thunk future)
|
||||
(lambda results
|
||||
(lambda ()
|
||||
result)))
|
||||
(apply values results)))))
|
||||
(lambda args
|
||||
(lambda ()
|
||||
(apply throw args)))))
|
||||
|
|
|
@ -75,6 +75,15 @@
|
|||
(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"
|
||||
(future? (future (throw 'foo 'bar))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue