File: relaying%2Csplit.R

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 (66 lines) | stat: -rw-r--r-- 1,446 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
source("incl/start.R")

options(future.debug = FALSE)

message("*** Relaying and split standard output and conditions ...")

message(" - default (implicit split = FALSE)")

plan(sequential)

relay <- recordRelay({
  f <- future({
    cat("O\n")
    message("M")
    1L
  })
})
message("  class: ", paste(sQuote(class(f)), collapse = ", "))
stopifnot(length(relay$stdout) == 0L)
stopifnot(length(relay$msgs) == 0L)
relay <- recordRelay(v <- value(f))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))


message(" - split = FALSE")

plan(sequential, split = FALSE)

relay <- recordRelay({
  f <- future({
    cat("O\n")
    message("M")
    1L
  })
})
message("  class: ", paste(sQuote(class(f)), collapse = ", "))
stopifnot(length(relay$stdout) == 0L)
stopifnot(length(relay$msgs) == 0L)
relay <- recordRelay(v <- value(f))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))


message(" - split = TRUE")

plan(sequential, split = TRUE)

relay <- recordRelay({
  f <- future({
    cat("O\n")
    message("M")
    1L
  })
})
message("  class: ", paste(sQuote(class(f)), collapse = ", "))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))
relay <- recordRelay(v <- value(f))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))


message("*** Relaying and split standard output and conditions ... DONE")

source("incl/end.R")