Files
clash-proxy/src-tauri/src/process/async_handler.rs

23 lines
519 B
Rust
Raw Normal View History

use std::future::Future;
use tauri::{async_runtime, async_runtime::JoinHandle};
pub struct AsyncHandler;
impl AsyncHandler {
pub fn spawn<F, Fut>(f: F) -> JoinHandle<()>
where
F: FnOnce() -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
{
async_runtime::spawn(f())
}
pub fn spawn_blocking<T, F>(f: F) -> JoinHandle<T>
where
F: FnOnce() -> T + Send + 'static,
T: Send + 'static,
{
async_runtime::spawn_blocking(f)
}
}