R/nbrOfFreeWorkers.R

#' @importFrom future nbrOfWorkers nbrOfFreeWorkers
#' @export
nbrOfFreeWorkers.callr <- local({
  function(evaluator = NULL, background = FALSE, ...) {
  #  assert_no_positional_args_but_first()
    workers <- nbrOfWorkers(evaluator)
    usedWorkers <- length(FutureRegistry("workers-callr", action = "list",
                          earlySignal = FALSE))
    workers <- workers - usedWorkers
    stop_if_not(length(workers) == 1L, !is.na(workers), workers >= 
        0L, is.finite(workers))
    workers
  }
})

Try the future.callr package in your browser

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

future.callr documentation built on Aug. 10, 2023, 1:07 a.m.