mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-15 15:32:21 +08:00
39 lines
1.3 KiB
Rust
Executable File
39 lines
1.3 KiB
Rust
Executable File
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
|
use std::process::ExitCode;
|
|
#[cfg(not(all(feature = "perf-harness", target_os = "macos")))]
|
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
|
|
|
#[cfg(all(feature = "perf-harness", target_os = "macos"))]
|
|
#[path = "../../scripts/perf/app.rs"]
|
|
mod perf;
|
|
|
|
#[cfg(all(feature = "perf-harness", target_os = "macos"))]
|
|
fn main() -> ExitCode {
|
|
perf::run()
|
|
}
|
|
|
|
#[cfg(not(all(feature = "perf-harness", target_os = "macos")))]
|
|
fn main() -> ExitCode {
|
|
let default_parallelism = std::thread::available_parallelism().map_or(1, |n| n.get());
|
|
let worker_limit = std::cmp::min(default_parallelism, 4);
|
|
let blocking_limit = 2 * worker_limit;
|
|
|
|
#[allow(clippy::unwrap_used)]
|
|
let tokio_runtime = tokio::runtime::Builder::new_multi_thread()
|
|
.worker_threads(worker_limit)
|
|
.max_blocking_threads(blocking_limit)
|
|
.enable_all()
|
|
.thread_name_fn(|| {
|
|
static ATOMIC_ID: AtomicUsize = AtomicUsize::new(0);
|
|
let id = ATOMIC_ID.fetch_add(1, Ordering::SeqCst);
|
|
format!("clash-verge-runtime-{id}")
|
|
})
|
|
.build()
|
|
.unwrap();
|
|
let tokio_handle = tokio_runtime.handle();
|
|
tauri::async_runtime::set(tokio_handle.clone());
|
|
|
|
app_lib::run()
|
|
}
|