File: sequential.Rd

package info (click to toggle)
r-cran-future 1.21.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,544 kB
  • sloc: sh: 14; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 2,030 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sequential.R
\name{sequential}
\alias{sequential}
\alias{uniprocess}
\alias{transparent}
\title{Create a sequential future whose value will be in the current \R session}
\usage{
sequential(..., envir = parent.frame())

transparent(..., envir = parent.frame())
}
\arguments{
\item{...}{Additional arguments passed to \code{\link[=Future]{Future()}}.}

\item{envir}{The \link{environment} from where global objects should be
identified.}
}
\value{
A \link{SequentialFuture}.
}
\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.
}
\details{
The preferred way to create a sequential future is not to call these functions
directly, but to register them via \code{\link{plan}(sequential)} such that
it becomes the default mechanism for all futures.  After this
\code{\link[=future]{future()}} and \code{\link{\%<-\%}} will create
\emph{sequential futures}.
}
\section{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 \code{local()} as default for all other
types of futures).  This makes transparent futures ideal for
troubleshooting, especially when there are errors.
}

\examples{
## 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)
}