diff --git a/R/Future-class.R b/R/Future-class.R index 8f1e2a33..b6a39b07 100644 --- a/R/Future-class.R +++ b/R/Future-class.R @@ -659,7 +659,7 @@ getExpression <- function(future, ...) UseMethod("getExpression") getExpression.Future <- local({ tmpl_expr_evaluate2 <- bquote_compile({ ## Evaluate future - future:::evalFuture(core = .(core), capture = .(capture), local = .(local), split = .(split), immediateConditionClasses = .(immediateConditionClasses), strategiesR = .(strategiesR), forwardOptions = .(forwardOptions), threads = .(threads), cleanup = .(cleanup)) + future:::evalFuture(core = .(core), capture = .(capture), context = .(context), split = .(split), immediateConditionClasses = .(immediateConditionClasses), forwardOptions = .(forwardOptions), local = .(local), cleanup = .(cleanup)) }) function(future, expr = future$expr, immediateConditions = FALSE, mc.cores = NULL, threads = NA_integer_, cleanup = TRUE, ...) { @@ -739,6 +739,11 @@ getExpression.Future <- local({ conditionClasses = conditionClasses ) + context <- list( + threads = threads, + strategiesR = strategiesR + ) + forwardOptions <- list( ## Assert globals when future is created (or at run time)? future.globals.onMissing = getOption("future.globals.onMissing"), diff --git a/R/expressions.R b/R/expressions.R index 572656c3..66d0bf54 100644 --- a/R/expressions.R +++ b/R/expressions.R @@ -15,12 +15,14 @@ evalFuture <- function( stdout = TRUE, conditionClasses = character(0L) ), - local = FALSE, + context = list( + strategiesR = NULL, + threads = NA_integer_ + ), split = FALSE, immediateConditionClasses = character(0L), forwardOptions = NULL, - strategiesR = NULL, - threads = NA_integer_, + local = FALSE, envir = parent.frame(), cleanup = TRUE) { expr <- core$expr @@ -32,6 +34,10 @@ evalFuture <- function( if (is.null(stdout)) stdout <- TRUE conditionClasses <- capture$conditionClasses + strategiesR <- context$strategiesR + threads <- context$threads + if (is.null(threads)) threads <- NA_integer_ + stop_if_not( length(local) == 1L && is.logical(local) && !is.na(local), length(stdout) == 1L && is.logical(stdout),