R/mirai_cluster.R

Defines functions tweak.mirai_cluster mirai_cluster

Documented in mirai_cluster

#' Mirai-based cluster futures
#'
#' @inheritParams MiraiFuture
#' @inheritParams future::cluster
#'
#' @return An object of class [MiraiFuture].
#'
#' @example incl/mirai_cluster.R
#'
#' @export
mirai_cluster <- function(expr,
                               substitute = TRUE,
                               envir = parent.frame(),
                               ...) {
  if (substitute) expr <- substitute(expr)

  future <- MiraiFuture(
              expr = expr, substitute = FALSE,
              envir = envir,
              workers = NULL,
              ...
            )
  if(!isTRUE(future[["lazy"]])) future <- run(future)
  invisible(future)
}
class(mirai_cluster) <- c("mirai_cluster", "mirai", "multiprocess", "future", "function")
attr(mirai_cluster, "init") <- TRUE


#' @importFrom future tweak
#' @export
tweak.mirai_cluster <- function(strategy, ..., penvir = parent.frame()) {
  attr(strategy, "init") <- TRUE
  NextMethod("tweak")
}

Try the future.mirai package in your browser

Any scripts or data that you put into this service are public.

future.mirai documentation built on July 3, 2024, 5:06 p.m.