use std::sync::atomic::{AtomicBool, Ordering};
pub fn init_with_config(config: crate::config::GlobalExecutorConfig) {
let _ = crate::config::GLOBAL_EXECUTOR_CONFIG.set(config.seal());
init();
}
pub fn init() {
static INIT_DONE: AtomicBool = AtomicBool::new(false);
if !INIT_DONE.swap(true, Ordering::SeqCst) {
let config =
crate::config::GLOBAL_EXECUTOR_CONFIG.get_or_init(crate::config::Config::default);
crate::reactor::block_on(async {
crate::threading::spawn_more_threads(config.min_threads)
.await
.expect("cannot spawn executor threads");
});
}
}