Last chance! 50% off unlimited learning
Sale ends in
eager(expr, envir = parent.frame(), substitute = TRUE, globals = TRUE, local = TRUE, earlySignal = FALSE, label = NULL, ...)
expr
is
substitute()
:ed, otherwise not.future()
and futureCall()
.local()
as default for all other
types of futures). This makes transparent futures ideal for
troubleshooting, especially when there are errors.plan(eager)
such that it
becomes the default mechanism for all futures. After this
future()
and %<-%
will create
eager futures.
## Use eager futures
plan(eager)
## A global variable
a <- 0
## Create eager future (explicitly)
f <- future({
b <- 3
c <- 2
a * b * c
})
## Since 'a' is a global variable in _eager_ future 'f',
## it already has been resolved, 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)
Run the code above in your browser using DataLab