Skip to content

Commit 54e59fe

Browse files
Add minifuture()
1 parent ccdf4b9 commit 54e59fe

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export(makeClusterPSOCK)
141141
export(makeNodePSOCK)
142142
export(mandelbrot)
143143
export(mandelbrot_tiles)
144+
export(minifuture)
144145
export(multicore)
145146
export(multisession)
146147
export(nbrOfFreeWorkers)

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
but now it's handled automatically by the future framework.
1010

1111
* Add new FutureBackend API for writing future backends.
12+
13+
* Add `minifuture()`, which is like `future()`, but with different
14+
default arguments resulting in less overhead with the added burden
15+
on having to specify globals and packages, not having conditions
16+
and standard output relayed, and ignoring random number generation.
1217

1318
## Bug Fixes
1419

R/utils_api-minifuture.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#' Create a minimalistic future with minimal automatic features
2+
#'
3+
#' Same as [future()], but with different default arguments. Specifically,
4+
#' globals and packages must be manually specified, conditions are not
5+
#' captured, standard output is not captured, random seeds are not declared
6+
#' or set.
7+
#'
8+
#' @inheritParams future
9+
#'
10+
#' @param expr An \R \link[base]{expression}.
11+
#'
12+
#' @param \ldots Additional arguments passed to [future()].
13+
#'
14+
#' @return A [Future]
15+
#' @export
16+
minifuture <- function(expr, substitute = TRUE, globals = NULL, packages = NULL, stdout = NA, conditions = NULL, seed = NULL, ..., envir = parent.frame()) {
17+
if (substitute) expr <- substitute(expr)
18+
reset <- character(0L)
19+
future(expr, substitute = FALSE, globals = globals, packages = packages, stdout = stdout, conditions = conditions, seed = seed, reset = reset, ..., envir = envir)
20+
}

man/minifuture.Rd

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

0 commit comments

Comments
 (0)