chore: 调整项目演示程序目录结构

This commit is contained in:
Del Wang
2025-04-26 21:46:32 +08:00
parent 39febdfe57
commit c3cac9b2b4
54 changed files with 25 additions and 23 deletions
+18
View File
@@ -0,0 +1,18 @@
use std::future::Future;
use once_cell::sync::OnceCell;
use tokio::runtime::Runtime;
static RUNTIME: OnceCell<Runtime> = OnceCell::new();
pub fn runtime() -> &'static Runtime {
RUNTIME.get_or_try_init(Runtime::new).unwrap()
}
pub fn run_async<F>(future: F)
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
runtime().spawn(future);
}