R/parallel.R

Defines functions setup_parallel

Documented in setup_parallel

# Parallel functions

#' Set up parallel environment
#'
#' @return Nothing
setup_parallel <- function() {
  if (!requireNamespace("foreach", quietly = TRUE)) {
    # EXCLUDE COVERAGE START
    stop("foreach package required for parallel future operation",
         call. = FALSE)
    # EXCLUDE COVERAGE END
  }
  if (foreach::getDoParWorkers() == 1) {
    # EXCLUDE COVERAGE START
    warning("No parallel backend registered", call. = TRUE)
    # EXCLUDE COVERAGE END
  }
}

# if (.parallel) {
#   setup_parallel()
#
#   i <- seq_len(n)
#   fe_call <- as.call(c(list(quote(foreach::foreach), i = i), .paropts))
#   fe <- eval(fe_call)
#
#   result <- foreach::`%dopar%`(fe, do.ply(i))
# } else {
#   result <- loop_apply(n, do.ply)
# }

Try the merTools package in your browser

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

merTools documentation built on May 29, 2024, 7:05 a.m.