mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-06 07:23:43 +08:00
chore: optimize lock
This commit is contained in:
parent
46811f33ad
commit
10211d1d03
@ -339,18 +339,10 @@ impl Sysopt {
|
|||||||
/// read config from file directly
|
/// read config from file directly
|
||||||
pub fn guard_proxy(&self) {
|
pub fn guard_proxy(&self) {
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
let guard_state = self.guard_state.clone();
|
let guard_state = self.guard_state.clone();
|
||||||
|
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
// if it is running, exit
|
let _ = guard_state.lock().await;
|
||||||
let mut state = guard_state.lock().await;
|
|
||||||
if *state {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*state = true;
|
|
||||||
drop(state);
|
|
||||||
|
|
||||||
// default duration is 10s
|
// default duration is 10s
|
||||||
let mut wait_secs = 10u64;
|
let mut wait_secs = 10u64;
|
||||||
|
|
||||||
@ -402,10 +394,6 @@ impl Sysopt {
|
|||||||
log_err!(sysproxy.set_system_proxy());
|
log_err!(sysproxy.set_system_proxy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut state = guard_state.lock().await;
|
|
||||||
*state = false;
|
|
||||||
drop(state);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user