use futures::Future;
use hirofa_utils::task_manager::TaskManager;
use lazy_static::lazy_static;
use tokio::task::JoinError;
lazy_static! {
static ref HELPER_TASKS: TaskManager = TaskManager::new(std::cmp::max(2, num_cpus::get()));
}
pub fn add_helper_task<T>(task: T)
where
T: FnOnce() + Send + 'static,
{
log::trace!("adding a helper task");
HELPER_TASKS.add_task(task);
}
pub fn add_helper_task_async<R: Send + 'static, T: Future<Output = R> + Send + 'static>(
task: T,
) -> impl Future<Output = Result<R, JoinError>> {
log::trace!("adding an async helper task");
HELPER_TASKS.add_task_async(task)
}