Skip to content

Commit db8e2cd

Browse files
committed
rename isForkedChild() to isProcessForkedChild()
avoids a name collision with parallelly::isForkedChild(), which has slightly different semantics (it detects any forked child, whereas we detect a fork() occurring after RcppParallel was loaded).
1 parent 67c1f4f commit db8e2cd

6 files changed

Lines changed: 25 additions & 24 deletions

File tree

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export(LdFlags)
55
export(RcppParallel.package.skeleton)
66
export(RcppParallelLibs)
77
export(defaultNumThreads)
8-
export(isForkedChild)
8+
export(isProcessForkedChild)
99
export(setThreadOptions)
1010
export(tbbLibraryPath)

NEWS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11

22
## RcppParallel 6.0.0 (UNRELEASED)
33

4-
* RcppParallel now provides `isForkedChild()` (R) and
5-
`RcppParallel::isForkedChild()` (C++), which return `TRUE` when the current
6-
process is a `fork()` of the process in which RcppParallel was loaded.
4+
* RcppParallel now provides `isProcessForkedChild()` (R) and
5+
`RcppParallel::isProcessForkedChild()` (C++), which return `TRUE` when the
6+
current process is a `fork()` of the process in which RcppParallel was
7+
loaded.
78
Packages dispatching parallel work from within `parallel::mclapply()` (or
89
similar) should consult this and fall back to a serial path, as TBB does
910
not support use after fork. (#243)

R/fork.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#' Intel TBB — the parallel backend used by `parallelFor()` and
77
#' `parallelReduce()` — does not support being used in a child process after
88
#' `fork()`. Packages that may be invoked from within `parallel::mclapply()`
9-
#' or similar fork-based parallelism should call `isForkedChild()` and fall
10-
#' back to a serial code path when it returns `TRUE`.
9+
#' or similar fork-based parallelism should call `isProcessForkedChild()` and
10+
#' fall back to a serial code path when it returns `TRUE`.
1111
#'
1212
#' On Windows, which has no `fork()`, this always returns `FALSE`.
1313
#'
@@ -16,11 +16,11 @@
1616
#' @examples
1717
#' \dontrun{
1818
#' library(RcppParallel)
19-
#' isForkedChild()
20-
#' parallel::mclapply(1:2, function(i) RcppParallel::isForkedChild())
19+
#' isProcessForkedChild()
20+
#' parallel::mclapply(1:2, function(i) RcppParallel::isProcessForkedChild())
2121
#' }
2222
#'
2323
#' @export
24-
isForkedChild <- function() {
25-
.Call("isForkedChild", PACKAGE = "RcppParallel")
24+
isProcessForkedChild <- function() {
25+
.Call("isProcessForkedChild", PACKAGE = "RcppParallel")
2626
}

inst/include/RcppParallel/Fork.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace RcppParallel {
1010
// Intel TBB does not support being used after fork(). Code paths reachable
1111
// from fork()'d children (for example, via parallel::mclapply) should call
1212
// this and fall back to a serial implementation when it returns true.
13-
bool isForkedChild();
13+
bool isProcessForkedChild();
1414

1515
} // namespace RcppParallel
1616

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ namespace RcppParallel {
1313
#ifndef _WIN32
1414
static pid_t s_loadPid = 0;
1515

16-
bool isForkedChild()
16+
bool isProcessForkedChild()
1717
{
1818
return getpid() != s_loadPid;
1919
}
2020
#else
21-
bool isForkedChild()
21+
bool isProcessForkedChild()
2222
{
2323
return false;
2424
}
@@ -29,15 +29,15 @@ bool isForkedChild()
2929
/* .Call calls */
3030
extern "C" SEXP defaultNumThreads();
3131

32-
extern "C" SEXP isForkedChild()
32+
extern "C" SEXP isProcessForkedChild()
3333
{
34-
int forked = RcppParallel::isForkedChild() ? TRUE : FALSE;
34+
int forked = RcppParallel::isProcessForkedChild() ? TRUE : FALSE;
3535
return Rf_ScalarLogical(forked);
3636
}
3737

3838
static const R_CallMethodDef CallEntries[] = {
39-
{"defaultNumThreads", (DL_FUNC) &defaultNumThreads, 0},
40-
{"isForkedChild", (DL_FUNC) &isForkedChild, 0},
39+
{"defaultNumThreads", (DL_FUNC) &defaultNumThreads, 0},
40+
{"isProcessForkedChild", (DL_FUNC) &isProcessForkedChild, 0},
4141
{NULL, NULL, 0}
4242
};
4343

0 commit comments

Comments
 (0)