mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-13 05:20:28 +08:00
feat: limit blocking threads to 4, and naming tokio threads
This commit is contained in:
parent
781313e8f0
commit
b441f4b643
@ -10,6 +10,7 @@ mod feat;
|
||||
mod module;
|
||||
mod process;
|
||||
pub mod utils;
|
||||
|
||||
use crate::constants::files;
|
||||
use crate::{
|
||||
core::handle,
|
||||
|
||||
@ -1,5 +1,24 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
fn main() {
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let tokio_runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
// TODO: limit the number of worker threads
|
||||
// .worker_threads(4)
|
||||
.max_blocking_threads(4)
|
||||
.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());
|
||||
|
||||
#[cfg(feature = "tokio-trace")]
|
||||
console_subscriber::init();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user