Skip to content

Commit 73b6397

Browse files
getExpression(): Remove arguments 'stdout', 'split', and 'local'
getExpression() for ClusterFuture: Remove argument 'conditionClasses' and 'resignalImmediateConditions' getExpression() for MulticoreFuture: Remove argument 'conditionClasses' and 'resignalImmediateConditions'
1 parent 2345e72 commit 73b6397

File tree

5 files changed

+47
-50
lines changed

5 files changed

+47
-50
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future
2-
Version: 1.34.0-9100
2+
Version: 1.34.0-9101
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Imports:
55
digest,

R/ClusterFuture-class.R

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -656,37 +656,32 @@ getExpression.ClusterFuture <- local({
656656
})
657657

658658

659-
function(future, expr = future$expr, immediateConditions = TRUE, conditionClasses = future$conditions, resignalImmediateConditions = getOption("future.psock.relay.immediate", immediateConditions), ...) {
659+
function(future, expr = future$expr, immediateConditions = TRUE, ...) {
660660
## Assert that no arguments but the first is passed by position
661661
assert_no_positional_args_but_first()
662662

663663
## Inject code for resignaling immediateCondition:s?
664-
if (resignalImmediateConditions && immediateConditions) {
665-
## Preserve condition classes to be ignored
666-
exclude <- attr(conditionClasses, "exclude", exact = TRUE)
667-
668-
immediateConditionClasses <- getOption("future.relay.immediate", "immediateCondition")
669-
conditionClasses <- unique(c(conditionClasses, immediateConditionClasses))
670-
671-
if (length(conditionClasses) > 0L) {
672-
## Does the cluster node communicate with a connection?
673-
## (if not, it's via MPI)
674-
workers <- future$workers
675-
## AD HOC/FIXME: Here 'future$node' is yet not assigned, so we look at
676-
## the first worker and assume the others are the same. /HB 2019-10-23
677-
cl <- workers[1L]
678-
node <- cl[[1L]]
679-
con <- node$con
680-
if (!is.null(con)) {
681-
expr <- bquote_apply(tmpl_expr_conditions)
682-
} ## if (!is.null(con))
683-
} ## if (length(conditionClasses) > 0)
684-
685-
## Set condition classes to be ignored in case changed
686-
attr(conditionClasses, "exclude") <- exclude
664+
if (immediateConditions) {
665+
resignalImmediateConditions <- getOption("future.psock.relay.immediate", TRUE)
666+
if (resignalImmediateConditions) {
667+
immediateConditionClasses <- getOption("future.relay.immediate", "immediateCondition")
668+
if (length(immediateConditionClasses) > 0L) {
669+
## Does the cluster node communicate with a connection?
670+
## (if not, it's via MPI)
671+
workers <- future$workers
672+
## AD HOC/FIXME: Here 'future$node' is yet not assigned, so we look at
673+
## the first worker and assume the others are the same. /HB 2019-10-23
674+
cl <- workers[1L]
675+
node <- cl[[1L]]
676+
con <- node$con
677+
if (!is.null(con)) {
678+
expr <- bquote_apply(tmpl_expr_conditions)
679+
} ## if (!is.null(con))
680+
}
681+
}
687682
} ## if (resignalImmediateConditions && immediateConditions)
688683

689-
NextMethod(expr = expr, immediateConditions = immediateConditions, conditionClasses = conditionClasses)
684+
NextMethod(expr = expr, immediateConditions = immediateConditions)
690685
}
691686
})
692687

R/Future-class.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,14 @@ getExpression.Future <- local({
662662
future:::evalFuture(core = .(core), local = .(local), stdout = .(stdout), conditionClasses = .(conditionClasses), split = .(split), immediateConditions = .(immediateConditions), immediateConditionClasses = .(immediateConditionClasses), strategiesR = .(strategiesR), forwardOptions = .(forwardOptions), threads = .(threads), cleanup = .(cleanup))
663663
})
664664

665-
function(future, expr = future$expr, seed = future$seed, local = future$local, stdout = future$stdout, conditionClasses = future$conditions, split = future$split, immediateConditions = FALSE, mc.cores = NULL, threads = NA_integer_, cleanup = TRUE, ...) {
665+
function(future, expr = future$expr, conditionClasses = future$conditions, immediateConditions = FALSE, mc.cores = NULL, threads = NA_integer_, cleanup = TRUE, ...) {
666666
debug <- getOption("future.debug", FALSE)
667667
## mdebug("getExpression() ...")
668668

669+
local <- future$local
670+
stdout <- future$stdout
671+
split <- future$split
672+
669673
if (is.null(split)) split <- FALSE
670674
stop_if_not(is.logical(split), length(split) == 1L, !is.na(split))
671675

@@ -714,15 +718,14 @@ getExpression.Future <- local({
714718
expr = expr,
715719
globals = globals,
716720
packages = pkgs,
717-
seed = seed
721+
seed = future$seed
718722
)
719723

720-
conditionClassesExclude <- attr(conditionClasses, "exclude", exact = TRUE)
721-
muffleInclude <- attr(conditionClasses, "muffleInclude", exact = TRUE)
722-
if (is.null(muffleInclude)) muffleInclude <- "^muffle"
723-
724724
if (immediateConditions && !is.null(conditionClasses)) {
725725
immediateConditionClasses <- getOption("future.relay.immediate", "immediateCondition")
726+
conditionClassesExclude <- attr(conditionClasses, "exclude", exact = TRUE)
727+
muffleInclude <- attr(conditionClasses, "muffleInclude", exact = TRUE)
728+
if (is.null(muffleInclude)) muffleInclude <- "^muffle"
726729
conditionClasses <- unique(c(conditionClasses, immediateConditionClasses))
727730
attr(conditionClasses, "exclude") <- conditionClassesExclude
728731
attr(conditionClasses, "muffleInclude") <- muffleInclude

R/MulticoreFuture-class.R

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ result.MulticoreFuture <- function(future, ...) {
299299

300300
#' @export
301301
getExpression.MulticoreFuture <- local({
302-
function(future, expr = future$expr, mc.cores = 1L, immediateConditions = TRUE, conditionClasses = future$conditions, resignalImmediateConditions = getOption("future.multicore.relay.immediate", immediateConditions), ...) {
302+
function(future, expr = future$expr, mc.cores = 1L, immediateConditions = TRUE, ...) {
303303
## Assert that no arguments but the first is passed by position
304304
assert_no_positional_args_but_first()
305305

@@ -318,22 +318,17 @@ getExpression.MulticoreFuture <- local({
318318
}
319319

320320
## Inject code for resignaling immediateCondition:s?
321-
if (resignalImmediateConditions && immediateConditions) {
322-
## Preserve condition classes to be ignored
323-
exclude <- attr(conditionClasses, "exclude", exact = TRUE)
324-
325-
immediateConditionClasses <- getOption("future.relay.immediate", "immediateCondition")
326-
conditionClasses <- unique(c(conditionClasses, immediateConditionClasses))
327-
328-
if (length(conditionClasses) > 0L) {
329-
## Communicate via the file system
330-
expr <- bquote_apply(tmpl_expr_send_immediateConditions_via_file)
331-
} ## if (length(conditionClasses) > 0)
332-
333-
## Set condition classes to be ignored in case changed
334-
attr(conditionClasses, "exclude") <- exclude
321+
if (immediateConditions) {
322+
resignalImmediateConditions <- getOption("future.multicore.relay.immediate", TRUE)
323+
if (resignalImmediateConditions) {
324+
immediateConditionClasses <- getOption("future.relay.immediate", "immediateCondition")
325+
if (length(immediateConditionClasses) > 0L) {
326+
## Communicate via the file system
327+
expr <- bquote_apply(tmpl_expr_send_immediateConditions_via_file)
328+
}
329+
}
335330
} ## if (resignalImmediateConditions && immediateConditions)
336331

337-
NextMethod(expr = expr, mc.cores = mc.cores, immediateConditions = immediateConditions, conditionClasses = conditionClasses, threads = threads)
332+
NextMethod(expr = expr, mc.cores = mc.cores, immediateConditions = immediateConditions, threads = threads)
338333
}
339334
})

R/expressions.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ evalFuture <- function(core, local = FALSE, stdout = TRUE, conditionClasses = ch
2222
length(cleanup) == 1L && is.logical(cleanup) && !is.na(cleanup)
2323
)
2424

25+
if (!immediateConditions) {
26+
immediateConditionClasses <- character(0L)
27+
}
28+
2529
## Is it possible to force single-threaded processing?
2630
if (!is.na(threads)) {
2731
## Setting other than single-threaded processing is currently not
@@ -453,13 +457,13 @@ evalFuture <- function(core, local = FALSE, stdout = TRUE, conditionClasses = ch
453457
## Relay 'immediateCondition' conditions immediately?
454458
## If so, then do not muffle it and flag it as signalled
455459
## already here.
456-
signal <- immediateConditions && inherits(cond, immediateConditionClasses)
460+
signal <- inherits(cond, immediateConditionClasses)
457461
## Record condition
458462
...future.conditions[[length(...future.conditions) + 1L]] <<- list(
459463
condition = cond,
460464
signaled = as.integer(signal)
461465
)
462-
if (immediateConditions && !split && !signal) {
466+
if (length(immediateConditionClasses) > 0 && !split && !signal) {
463467
muffleCondition(cond, pattern = muffleInclude)
464468
}
465469
} else {

0 commit comments

Comments
 (0)