fix: tokio tasks

This commit is contained in:
Nova
2025-10-11 03:19:48 -07:00
parent b0ee7e9f54
commit c63416d1f3
6 changed files with 42 additions and 66 deletions

View File

@@ -1,23 +0,0 @@
use color_eyre::eyre::Result;
use std::future::Future;
use tokio::task::JoinHandle;
#[allow(unused_variables)]
pub fn new<
F: FnOnce() -> S,
S: AsRef<str>,
A: Future<Output = O> + Send + 'static,
O: Send + 'static,
>(
name_fn: F,
async_future: A,
) -> Result<JoinHandle<O>> {
#[cfg(not(feature = "profile_tokio"))]
let result = Ok(tokio::task::spawn(async_future));
#[cfg(feature = "profile_tokio")]
let result = tokio::task::Builder::new()
.name(name_fn().as_ref())
.spawn(async_future)
.map_err(Into::into);
result
}