File: stdout_OP.R

package info (click to toggle)
r-cran-future 1.11.1.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,380 kB
  • sloc: sh: 14; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 658 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
#' Control whether standard output should be captured or not
#'
#' @usage fassignment \%stdout\% capture
#'
#' @inheritParams multiprocess
#' 
#' @param fassignment The future assignment, e.g.
#'        \code{x \%<-\% \{ expr \}}.
#'
#' @param capture If TRUE, the standard output will be captured, otherwise not.
#'
#' @export
`%stdout%` <- function(fassignment, capture) {
  fassignment <- substitute(fassignment)
  envir <- parent.frame(1)

  ## Temporarily set 'lazy' argument
  args <- getOption("future.disposable", list())
  args["stdout"] <- list(capture)
  options(future.disposable = args)

  eval(fassignment, envir = envir, enclos = baseenv())
}