File: ConstantFuture-class.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 (22 lines) | stat: -rw-r--r-- 752 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
#' A future with a constant value
#'
#' A constant future is a future whose expression is a constant
#' and therefore by definition already resolved upon creation.
#'
#' @inheritParams Future-class
#' 
#' @param \dots Not used.
#'
#' @return An object of class \code{ConstantFuture}.
#'
#' @export
#' @name ConstantFuture-class
#' @keywords internal
ConstantFuture <- function(expr = NULL, envir = emptyenv(), substitute = FALSE, globals = NULL, packages = NULL, local = FALSE, ...) {
  expr <- force(expr)
  f <- Future(expr = expr, envir = emptyenv(), substitute = FALSE, globals = NULL, packages = NULL, local = FALSE, ...)
  f$result <- FutureResult(value = expr)
  f$state <- "finished"
  structure(f, class = c("ConstantFuture", class(f)))
  f
}