File: future%2Clazy.R

package info (click to toggle)
r-cran-future.batchtools 0.12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 528 kB
  • sloc: sh: 82; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (3)
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
source("incl/start.R")

message("*** Futures - lazy ...")

strategies <- c("batchtools_local")

## CRAN processing times:
## On Windows 32-bit, don't run these tests
if (!fullTest && isWin32) strategies <- character(0L)

for (strategy in strategies) {
  mprintf("- plan('%s') ...\n", strategy)
  plan(strategy)

  a <- 42
  f <- future(2 * a, lazy = TRUE)
  a <- 21
  ## In future (> 1.14.0), resolved() will launch lazy future,
  ## which means for some backends (e.g. sequential) this means
  ## that resolved() might end up returning TRUE.
  f <- resolve(f)
  stopifnot(resolved(f))
  v <- value(f)
  stopifnot(v == 84)

  a <- 42
  v %<-% { 2 * a } %lazy% TRUE
  a <- 21
  f <- futureOf(v)  
  ## In future (> 1.14.0), resolved() will launch lazy future,
  ## which means for some backends (e.g. sequential) this means
  ## that resolved() might end up returning TRUE.
  f <- resolve(f)
  stopifnot(resolved(f))
  stopifnot(v == 84)

  mprintf("- plan('%s') ... DONE\n", strategy)
} ## for (strategy ...)

message("*** Futures - lazy ... DONE")

source("incl/end.R")