survrecThreads: Number of threads used by survrec

View source: R/threads.R

survrecThreadsR Documentation

Number of threads used by survrec

Description

Gets or sets the maximum number of threads used by the parallel parts of the package, currently the re-estimation phase of the bootstrap in survdiffr(), which refits the survival curve once per bootstrap replicate.

Usage

survrecThreads(n)

Arguments

n

Maximum number of threads, or NULL to restore the default (let OpenMP decide). If missing, the current setting is returned without changing it.

Details

By default the package lets OpenMP decide, which means it honours the OMP_NUM_THREADS environment variable. Set this option to cap the number of threads regardless of that variable, for instance when running inside a shared machine or a job scheduler.

The bootstrap resampling itself always runs serially because it draws from R's random number generator (which is not thread-safe); results are therefore reproducible with set.seed() independently of the number of threads.

If the package was built without OpenMP support (which is the case with the default compiler on macOS), the computation runs sequentially and this setting has no effect.

Value

The current setting, invisibly when it is being changed. NULL means "let OpenMP decide".

Examples

survrecThreads() # current setting

old <- survrecThreads(2)
survrecThreads(old) # restore

survrec documentation built on Sept. 22, 2026, 9:07 a.m.