Create a deferred value that is resolved when all listed deferred values
are resolved. Note that the error of an input deferred value
triggers the error when_all as well.
when_all(..., .list = list())A deferred value, that is conditioned on all deferred values
in ... and .list.
async has auto-cancellation, so if one deferred value errors, the rest of them will be automatically cancelled.
httpbin <- webfakes::new_app_process(
webfakes::httpbin_app(),
opts = webfakes::server_opts(num_threads = 3)
)
## Check that the contents of two URLs are the same
afun <- async(function() {
u1 <- http_get(httpbin$url("/get"))
u2 <- http_get(httpbin$url("/get"))
when_all(u1, u2)$
then(function(x) identical(x[[1]]$content, x[[2]]$content))
})
synchronise(afun())
#> [1] TRUE