multiprocess {future} | R Documentation |
A multiprocess future is a future that uses multicore evaluation if supported, otherwise it uses multisession evaluation. Regardless, its value is computed and resolved in parallel in another process.
multiprocess( expr, envir = parent.frame(), substitute = TRUE, lazy = FALSE, seed = NULL, globals = TRUE, workers = availableCores(), gc = FALSE, earlySignal = FALSE, label = NULL, ... )
expr |
An R expression. |
envir |
The environment from where global objects should be identified. |
substitute |
If TRUE, argument |
lazy |
If |
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 |
workers |
A positive numeric scalar or a function specifying the maximum number of parallel futures that can be active at the same time before blocking. If a function, it is called without arguments when the future is created and its value is used to configure the workers. The function should return a numeric scalar. |
gc |
If TRUE, the garbage collector run (in the process that
evaluated the future) only after the value of the future is collected.
Exactly when the values are collected may depend on various factors such
as number of free workers and whether |
earlySignal |
Specified whether conditions should be signaled as soon as possible or not. |
label |
An optional character string label attached to the future. |
... |
Additional named elements passed to |
A MultiprocessFuture implemented as either a MulticoreFuture or a MultisessionFuture.
Internally multicore()
and multisession()
are used.
## Use multiprocess futures plan(multiprocess) ## A global variable a <- 0 ## Create future (explicitly) f <- future({ b <- 3 c <- 2 a * b * c }) ## A multiprocess future is evaluated in a separate R process. ## Changing the value of a global variable will not affect ## the result of the future. a <- 7 print(a) v <- value(f) print(v) stopifnot(v == 0)