Skip to content

Commit bd73ee5

Browse files
Remove argument 'run' from resolved()
1 parent f1ac535 commit bd73ee5

File tree

9 files changed

+55
-34
lines changed

9 files changed

+55
-34
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
Sys.setenv(R_FUTURE_FUTURE_LOCAL = "defunct")
138138
Sys.setenv(R_FUTURE_FUTURE_GC = "defunct")
139139
Sys.setenv(R_FUTURE_PLAN_EARLYSIGNAL = "defunct")
140+
Sys.setenv(R_FUTURE_RESOLVED_RUN = "defunct")
140141
}
141142
if (nzchar(Sys.getenv("R_FUTURE_PLAN")) || getRversion() < "3.5.0") Sys.setenv(RCMDCHECK_ERROR_ON = "error")
142143
rcmdcheck::rcmdcheck(
@@ -158,6 +159,7 @@ jobs:
158159
Sys.setenv(R_FUTURE_FUTURE_LOCAL = "defunct")
159160
Sys.setenv(R_FUTURE_FUTURE_GC = "defunct")
160161
Sys.setenv(R_FUTURE_PLAN_EARLYSIGNAL = "defunct")
162+
Sys.setenv(R_FUTURE_RESOLVED_RUN = "defunct")
161163
}
162164
rcmdcheck::rcmdcheck(
163165
args = c("--no-manual", "--as-cran",

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.68.0-9031
2+
Version: 1.68.0-9032
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Depends:
55
R (>= 3.2.0)

NEWS.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222

2323
## Deprecated and Defunct
2424

25+
* The `cluster` backend now defaults to `earlySignal = FALSE`. This
26+
was effectively already the case, because of an internal thinko
27+
bug.
28+
2529
* Remove arguments `earlySignal` and `gc` from `future()`,
2630
`futureAssign()`, and `futureCall()`. Attempts to set them produce
2731
deprecation warnings. Deprecated also hidden argument `local`,
@@ -30,9 +34,8 @@
3034
* Use of `plan(..., earlySignal = ...)` is now defunct and produces a
3135
deprecation warning.
3236

33-
* The `cluster` backend now defaults to `earlySignal = FALSE`. This
34-
was effectively already the case, because of an internal thinko
35-
bug.
37+
* Remove argument `run` from `resolved()`. Attempts to set it
38+
produces a deprecation warning.
3639

3740
* Remove internal future field `envir`.
3841

R/009.deprecation.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
deprecateArgument <- function(fcn, name, value) {
2-
fcn <- match.arg(fcn, choices = c("future", "plan"))
2+
fcn <- match.arg(fcn, choices = c("future", "plan", "resolved"))
33
option <- sprintf("future.%s.%s", fcn, name)
44
action <- getOption(option, "deprecated")
55
action <- match.arg(action, choices = c("deprecated", "defunct", "ignore"))

R/backend_api-11.ClusterFutureBackend-class.R

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,18 +580,25 @@ getSocketSelectTimeout <- function(future, timeout = NULL) {
580580
#' @rdname resolved
581581
#' @importFrom parallelly connectionId isConnectionValid
582582
#' @export
583-
resolved.ClusterFuture <- function(x, run = TRUE, timeout = NULL, ...) {
583+
resolved.ClusterFuture <- function(x, timeout = NULL, ...) {
584584
debug <- isTRUE(getOption("future.debug"))
585585

586586
future <- x
587587
backend <- future[["backend"]]
588588
stop_if_not(inherits(backend, "FutureBackend"))
589589
workers <- backend[["workers"]]
590590
reg <- backend[["reg"]]
591-
591+
592+
args <- list(...)
593+
run <- args[["run"]]
594+
595+
if (!is.null(run)) {
596+
deprecateArgument("resolved", "run", run)
597+
}
598+
592599
## A lazy future not even launched?
593600
if (future[["state"]] == "created") {
594-
if (run) {
601+
if (!isFALSE(run)) {
595602
nworkers <- length(workers)
596603

597604
## Collect one resolved future, if one exists
@@ -612,7 +619,7 @@ resolved.ClusterFuture <- function(x, run = TRUE, timeout = NULL, ...) {
612619

613620
## 4. Launch this lazy future
614621
if (any(avail)) future <- run(future)
615-
} ## if (run)
622+
} ## if (!isFALSE(run))
616623

617624
## Consider future non-resolved
618625
return(FALSE)

R/backend_api-11.MulticoreFutureBackend-class.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,17 @@ nbrOfFreeWorkers.MulticoreFutureBackend <- function(evaluator, background = FALS
280280
resolved.MulticoreFuture <- local({
281281
selectChildren <- import_parallel_fcn("selectChildren")
282282

283-
function(x, run = TRUE, timeout = NULL, ...) {
283+
function(x, timeout = NULL, ...) {
284+
args <- list(...)
285+
run <- args[["run"]]
286+
287+
if (!is.null(run)) {
288+
deprecateArgument("resolved", "run", run)
289+
}
290+
284291
## A lazy future not even launched?
285292
if (x[["state"]] == "created") {
286-
if (run) {
293+
if (!isFALSE(run)) {
287294
## If free cores are available, then launch this lazy future
288295
if (x[["workers"]] > usedCores()) x <- run(x)
289296
}

R/core_api-resolved.R

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#' @param x A \link{Future}, a list, or an environment (which also
44
#' includes \link[listenv:listenv]{list environment}).
55
#'
6-
#' @param run (logical) If TRUE, any lazy futures is launched,
7-
#' otherwise not.
8-
#'
96
#' @param \ldots Not used.
107
#'
118
#' @return
@@ -15,13 +12,13 @@
1512
#' It never signals an error.
1613
#'
1714
#' @details
18-
#' `resolved(..., run = TRUE)` attempts to launch a lazy future, if there is
19-
#' an available worker, otherwise not.
15+
#' `resolved()` attempts to launch a lazy future, if there is an available
16+
#' worker, otherwise not.
2017
#'
2118
#' `resolved()` methods must always return `TRUE` or `FALSE` values, must
22-
#' always launch lazy futures by default (`run = TRUE`), and must never block
23-
#' indefinitely. This is because it should always be possible to poll futures
24-
#' until they are resolved using `resolved()`, e.g.
19+
#' always launch lazy futures, and must never block indefinitely. This is
20+
#' because it should always be possible to poll futures until they are
21+
#' resolved using `resolved()`, e.g.
2522
#' `while (!all(resolved(futures))) Sys.sleep(5)`.
2623
#'
2724
#' Each future backend must implement a `resolved()` method. It should return
@@ -122,19 +119,26 @@ resolved.environment <- function(x, ...) {
122119

123120
#' @rdname resolved
124121
#' @export
125-
resolved.Future <- function(x, run = TRUE, ...) {
122+
resolved.Future <- function(x, ...) {
126123
future <- x
124+
args <- list(...)
125+
run <- args[["run"]]
126+
127127
debug <- isTRUE(getOption("future.debug"))
128128
if (debug) {
129129
mdebugf_push("resolved() for %s (%s) ...", class(future)[1], sQuoteLabel(future))
130130
on.exit(mdebug_pop())
131131
mdebug("state: ", sQuote(future[["state"]]))
132-
mdebug("run: ", run)
132+
mdebug("run: ", deparse(run))
133133
}
134-
134+
135+
if (!is.null(run)) {
136+
deprecateArgument("resolved", "run", run)
137+
}
138+
135139
## A lazy future not even launched?
136140
if (future[["state"]] == "created") {
137-
if (!run) return(FALSE)
141+
if (isFALSE(run)) return(FALSE)
138142
if (debug) mdebug_push("run() ...")
139143
future <- run(future)
140144
if (debug) {

R/utils-options.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,5 +471,6 @@ update_package_options <- function(debug = FALSE) {
471471
update_package_option("future.future.gc", mode = "character", debug = debug)
472472
update_package_option("future.future.local", mode = "character", debug = debug)
473473
update_package_option("future.plan.earlySignal", mode = "character", debug = debug)
474+
update_package_option("future.resolved.run", mode = "character", debug = debug)
474475
update_package_option("future.Future.envir.keep", mode = "logical", debug = debug)
475476
}

man/resolved.Rd

Lines changed: 8 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)