future (version 1.3.0)

multiprocess: Create a multiprocess future whose value will be resolved asynchronously using multicore or a multisession evaluation

Description

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.

Usage

multiprocess(expr, envir = parent.frame(), substitute = TRUE,
  lazy = FALSE, seed = NULL, globals = TRUE, workers = availableCores(),
  gc = FALSE, earlySignal = FALSE, label = NULL, ...)

Arguments

expr
An R expression to be evaluated.
envir
The environment from where global objects should be identified. Depending on the future strategy (the evaluator), it may also be the environment in which the expression is evaluated.
substitute
If TRUE, argument expr is substitute():ed, otherwise not.
lazy
If FALSE (default), the future is resolved eagerly (immediately), otherwise not.
seed
(optional) A L'Ecuyer-CMRG RNG seed.
globals
(optional) a logical, a character vector, or a named list for controlling how globals are handled. For details, see section 'Globals used by future expressions' in the help for future().
workers
The maximum number of multiprocess futures that can be active at the same time before blocking.
gc
If TRUE, the garbage collector run (in the process that evaluated the future) after the value of the future is collected.
earlySignal
Specified whether conditions should be signaled as soon as possible or not.
label
An optional character string label attached to the future.
...
Not used.

Value

A MultiprocessFuture implemented as either a MulticoreFuture or a MultisessionFuture.

See Also

Internally multicore() and multisession() are used.

Examples

Run this code

## Use multiprocess futures
plan(multiprocess)

## A global variable
a <- 0

## Create multicore 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)


Run the code above in your browser using DataLab