use std::sync::Once;
static INIT: Once = Once::new();
pub fn init_runtime() {
INIT.call_once(|| {
let workers = std::thread::available_parallelism()
.map(|n| n.get())
.unwrap_or(2);
let runtime = dtact::GLOBAL_RUNTIME.get_or_init(|| {
let scheduler = dtact::dta_scheduler::DtaScheduler::new(
workers,
dtact::dta_scheduler::TopologyMode::P2PMesh,
);
let pool = dtact::memory_management::ContextPool::new(
512,
524_288,
dtact::memory_management::SafetyLevel::Safety1,
0,
)
.expect("test runtime init failed");
dtact::Runtime {
scheduler,
pool,
started: core::sync::atomic::AtomicBool::new(false),
shutdown: core::sync::atomic::AtomicBool::new(false),
}
});
runtime.start();
std::thread::sleep(std::time::Duration::from_millis(30));
});
}