upend/server/src/util/exec.rs

18 lines
431 B
Rust

use actix_web::web;
pub fn block_background<F, I, E>(f: F)
where
F: FnOnce() -> Result<I, E> + Send + 'static,
I: Send + 'static,
E: Send + std::fmt::Debug + 'static,
{
async fn inner<F, I, E>(f: F)
where
F: FnOnce() -> Result<I, E> + Send + 'static,
I: Send + 'static,
E: Send + std::fmt::Debug + 'static,
{
let _ = web::block(f).await;
}
actix::spawn(inner(f));
}