Skip to content

Commit

Permalink
evalFuture(): Add argument 'context'; dropped 'strategiesR' and 'thre…
Browse files Browse the repository at this point in the history
…ads'
  • Loading branch information
HenrikBengtsson committed Jan 1, 2025
1 parent e5679f0 commit 6d8b2af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion R/Future-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) {
Expand Down Expand Up @@ -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"),
Expand Down
12 changes: 9 additions & 3 deletions R/expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand Down

0 comments on commit 6d8b2af

Please sign in to comment.