-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathfork.R
More file actions
26 lines (26 loc) · 870 Bytes
/
Copy pathfork.R
File metadata and controls
26 lines (26 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#' Is the Current Process a Forked Child?
#'
#' Returns `TRUE` if the current process is a `fork()` of the process in which
#' RcppParallel was originally loaded.
#'
#' Intel TBB — the parallel backend used by `parallelFor()` and
#' `parallelReduce()` — does not support being used in a child process after
#' `fork()`. Packages that may be invoked from within `parallel::mclapply()`
#' or similar fork-based parallelism should call `isForkedChild()` and fall
#' back to a serial code path when it returns `TRUE`.
#'
#' On Windows, which has no `fork()`, this always returns `FALSE`.
#'
#' @return A length-one logical.
#'
#' @examples
#' \dontrun{
#' library(RcppParallel)
#' isForkedChild()
#' parallel::mclapply(1:2, function(i) RcppParallel::isForkedChild())
#' }
#'
#' @export
isForkedChild <- function() {
.Call("isForkedChild", PACKAGE = "RcppParallel")
}