Temporarily configures the Rust worker thread pool to n threads for the duration of evaluating code, and automatically restores the previous thread allocation when code finishes (even if an error occurs).

with_hpc_threads(n, code)

Arguments

n

integer number of worker threads to use during execution.

code

expression or code block to evaluate.

Value

The result of evaluating code.

Examples

if (FALSE) { # \dontrun{
  res <- with_hpc_threads(2, {
    graphSmooth(spc_cube, width = 50, height = 50, alpha = 0.5)
  })
} # }