diff --git a/DESCRIPTION b/DESCRIPTION index e9cd02401..a26e20eef 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mirai Type: Package Title: Minimalist Async Evaluation Framework for R -Version: 1.2.0.9029 +Version: 1.2.0.9030 Description: Designed for simplicity, a 'mirai' evaluates an R expression asynchronously in a parallel process, locally or distributed over the network, with the result automatically available upon completion. Modern diff --git a/NEWS.md b/NEWS.md index 3fe55356a..96687a263 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# mirai 1.2.0.9029 (development) +# mirai 1.2.0.9030 (development) #### New Features diff --git a/R/promises.R b/R/promises.R index 52a6b854e..df597d0c6 100644 --- a/R/promises.R +++ b/R/promises.R @@ -68,22 +68,23 @@ as.promise.mirai <- function(x) { if (is.null(promise)) { - if (unresolved(x)) { - promise <- promises::then( - promises::promise( - function(resolve, reject) .keep(x, environment()) - ), + promise <- if (.unresolved(x)) { + promises::promise( + function(resolve, reject) .keep(x, environment()) + )$then( onFulfilled = function(value) if (is_error_value(value) && !is_mirai_interrupt(value)) stop(if (is_mirai_error(value)) value else nng_error(value)) else value ) - } else { - value <- .subset2(x, "value") - promise <- if (is_error_value(value) && !is_mirai_interrupt(value)) - promises::promise_reject(if (is_mirai_error(value)) value else nng_error(value)) else - promises::promise_resolve(value) + value <- collect_aio(x) + promises::promise( + function(resolve, reject) + if (is_error_value(value) && !is_mirai_interrupt(value)) + reject(value) else + resolve(value) + ) } assign("promise", promise, x)