#[cfg(not(target_arch = "wasm32"))]
pub fn spawn_logged<F>(future: F)
where
F: std::future::Future<Output = ()> + 'static,
{
#[cfg(any(feature = "devtools", feature = "file-logging"))]
tracing::debug!(target: "burin", "spawned task");
auralis_task::spawn_global(future);
}
#[cfg(not(target_arch = "wasm32"))]
pub fn spawn_logged_with_priority<F>(priority: auralis_task::Priority, future: F)
where
F: std::future::Future<Output = ()> + 'static,
{
#[cfg(any(feature = "devtools", feature = "file-logging"))]
tracing::debug!(target: "burin", "spawned task (priority={priority:?})");
auralis_task::spawn_global_with_priority(priority, future);
}
#[cfg(feature = "async-tokio")]
static TOKIO_RT: std::sync::OnceLock<tokio::runtime::Runtime> = std::sync::OnceLock::new();
#[cfg(feature = "async-tokio")]
pub(crate) fn init_tokio() {
let rt = tokio::runtime::Builder::new_multi_thread()
.worker_threads(4)
.enable_all()
.build()
.expect("failed to create tokio runtime");
let _ = TOKIO_RT.set(rt);
}
#[cfg(feature = "async-tokio")]
pub fn spawn_background<F>(future: F)
where
F: std::future::Future<Output = ()> + Send + 'static,
{
TOKIO_RT
.get()
.expect("tokio runtime not initialised — call App::run() first")
.spawn(future);
}