future (version 1.0.1)

multiprocess: Create a multiprocess future whose value will be resolved asynchroneously 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, globals = TRUE, workers = availableCores(), gc = FALSE, earlySignal = FALSE, ...)

Arguments

expr
envir
The environment in which the evaluation is done and from which globals are obtained.
substitute
If TRUE, argument expr is substitute():ed, otherwise not.
globals
If TRUE, global objects are validated at the point in time when the future is created (always before it is resolved), that is, they identified and located. If some globals fail to be located, an informative error is generated.
workers
The maximum number of multiprocess futures that can be active at the same time before blocking.
gc
If TRUE, the garbage collector run after the future is resolved (in the process that evaluated the future).
earlySignal
Specified whether conditions should be signaled as soon as possible or not.
...
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
## Multiprocess futures gives an error on R CMD check on
## Windows (but not Linux or OS X) for unknown reasons.
## The same code works in package tests.


## 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