R/testthat-helpers.R

Defines functions use_local_plan

use_local_plan <- function(strategy, mc.cores = 2L, env = parent.frame()) {
  old_options <- options(mc.cores = 2)
  withr::defer(options(old_options), envir = env)
  
  old_strategy <- future::plan(strategy)
  withr::defer(future::plan(old_strategy), envir = env)
  strategy
}
poissonconsulting/sims documentation built on Jan. 17, 2025, 3:30 a.m.