Skip to content

Commit ee957bf

Browse files
Forgot to add file
1 parent dd5d0f4 commit ee957bf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#' @export
2+
nbrOfWorkers.BatchtoolsMultiprocessFutureBackend <- function(evaluator) {
3+
backend <- evaluator
4+
workers <- backend[["workers"]]
5+
if (!is.numeric(workers)) {
6+
workers <- length(workers)
7+
}
8+
workers
9+
}
10+
11+
12+
#' @export
13+
nbrOfFreeWorkers.BatchtoolsMultiprocessFutureBackend <- function(evaluator, background = FALSE, ...) {
14+
assert_no_positional_args_but_first()
15+
backend <- evaluator
16+
reg <- backend[["reg"]]
17+
usedWorkers <- length(FutureRegistry(reg, action = "list"))
18+
workers <- nbrOfWorkers() - usedWorkers
19+
stop_if_not(length(workers) == 1L, !is.na(workers), workers >= 0L)
20+
workers
21+
}

0 commit comments

Comments
 (0)