mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-30 18:10:04 +08:00
* docs(backend): define background task ownership * refactor(backend): give background operations single task owners * test(backend): remove actor migration regression cases * docs(changelog): drop backend actor migration entry * refactor(backend): extract workspace task drivers * fix(timer): omit profile identifier from panic log * docs(backend): define workspace crate boundaries * refactor(lightweight): use the task countdown driver * refactor(lightweight): name countdown callbacks * refactor(task): simplify driver startup and coalescing requests * refactor(core): bind service handoff to the sidecar generation * refactor(tun): coalesce background run state reconciliation * refactor(core): own sidecar exit resources in one session * refactor(core): remove automatic Windows service handoff * refactor(task): simplify coalescing job signals * refactor(runstate): keep operation status with service state * refactor(dns): coalesce background override synchronization * refactor(sysproxy): own the local guard under its operation lock * fix(tray): read menu settings at publication * fix(dns): retain script lock across caller cancellation * refactor(profiles): own selected node restoration in one task * refactor(timer): own subscription schedules in the scheduler * test(timer): remove the added application test * fix(service): renew provider sync retry budget on refresh
41 lines
935 B
Rust
41 lines
935 B
Rust
use std::future::Future;
|
|
use tauri::{async_runtime, async_runtime::JoinHandle};
|
|
|
|
pub struct AsyncHandler;
|
|
|
|
impl AsyncHandler {
|
|
pub(crate) fn start_driver<H>((handle, driver): (H, impl Future<Output = ()> + Send + 'static)) -> H {
|
|
Self::spawn(move || driver);
|
|
handle
|
|
}
|
|
|
|
#[inline]
|
|
#[track_caller]
|
|
pub fn spawn<F, Fut>(f: F) -> JoinHandle<()>
|
|
where
|
|
F: FnOnce() -> Fut + Send + 'static,
|
|
Fut: Future<Output = ()> + Send + 'static,
|
|
{
|
|
async_runtime::spawn(f())
|
|
}
|
|
|
|
#[inline]
|
|
#[track_caller]
|
|
pub fn spawn_blocking<T, F>(f: F) -> JoinHandle<T>
|
|
where
|
|
F: FnOnce() -> T + Send + 'static,
|
|
T: Send + 'static,
|
|
{
|
|
async_runtime::spawn_blocking(f)
|
|
}
|
|
|
|
#[inline]
|
|
#[track_caller]
|
|
pub fn block_on<Fut>(fut: Fut) -> Fut::Output
|
|
where
|
|
Fut: Future + Send + 'static,
|
|
{
|
|
async_runtime::block_on(fut)
|
|
}
|
|
}
|