sequential: Create a sequential future whose value will be in the current...

Description Usage Arguments Details Value transparent futures Examples

View source: R/sequential.R

Description

A sequential future is a future that is evaluated sequentially in the current R session similarly to how R expressions are evaluated in R. The only difference to R itself is that globals are validated by default just as for all other types of futures in this package.

Usage

1
2
3
4
5
6
7
sequential(expr, envir = parent.frame(), substitute = TRUE,
  lazy = FALSE, seed = NULL, globals = TRUE, local = TRUE,
  earlySignal = FALSE, label = NULL, ...)

transparent(expr, envir = parent.frame(), substitute = TRUE,
  lazy = FALSE, seed = NULL, globals = FALSE, local = FALSE,
  earlySignal = TRUE, label = NULL, ...)

Arguments

expr

An R expression.

envir

The environment from where global objects should be identified.

substitute

If TRUE, argument expr is substitute():ed, otherwise not.

lazy

If FALSE (default), the future is resolved eagerly (starting immediately), otherwise not.

seed

(optional) A L'Ecuyer-CMRG RNG seed.

globals

(optional) a logical, a character vector, or a named list to control how globals are handled. For details, see section 'Globals used by future expressions' in the help for future().

local

If TRUE, the expression is evaluated such that all assignments are done to local temporary environment, otherwise the assignments are done in the calling environment.

earlySignal

Specified whether conditions should be signaled as soon as possible or not.

label

An optional character string label attached to the future.

...

Reserved for internal use only.

Details

The preferred way to create a sequential future is not to call these functions directly, but to register them via plan(sequential) such that it becomes the default mechanism for all futures. After this future() and %<-% will create sequential futures.

Value

A SequentialFuture.

transparent futures

Transparent futures are sequential futures configured to emulate how R evaluates expressions as far as possible. For instance, errors and warnings are signaled immediately and assignments are done to the calling environment (without local() as default for all other types of futures). This makes transparent futures ideal for troubleshooting, especially when there are errors.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Use sequential futures
plan(sequential)

## A global variable
a <- 0

## Create a sequential future
f <- future({
  b <- 3
  c <- 2
  a * b * c
})

## Since 'a' is a global variable in future 'f' which
## is eagerly resolved (default), this global has already
## been resolved / incorporated, and any changes to 'a'
## at this point will _not_ affect the value of 'f'.
a <- 7
print(a)

v <- value(f)
print(v)
stopifnot(v == 0)

future documentation built on Nov. 8, 2019, 5:06 p.m.