mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-31 19:32:13 +08:00
refactor(deps): replace once_cell with std OnceLock and LazyLock (#8136)
This commit is contained in:
@@ -7,12 +7,12 @@ use crate::{
|
||||
};
|
||||
use anyhow::{Context as _, Result, bail};
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use once_cell::sync::OnceCell;
|
||||
use parking_lot::Mutex;
|
||||
use reqwest::ClientBuilder;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::{Read as _, Write as _};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::OnceLock;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::Duration;
|
||||
use tokio::sync::oneshot;
|
||||
@@ -33,9 +33,9 @@ struct InstanceRecord {
|
||||
token: String,
|
||||
}
|
||||
|
||||
static SHUTDOWN_SENDER: OnceCell<Mutex<Option<oneshot::Sender<()>>>> = OnceCell::new();
|
||||
static EMBEDDED_PORT: OnceCell<u16> = OnceCell::new();
|
||||
static INSTANCE_LOCK: OnceCell<std::fs::File> = OnceCell::new();
|
||||
static SHUTDOWN_SENDER: OnceLock<Mutex<Option<oneshot::Sender<()>>>> = OnceLock::new();
|
||||
static EMBEDDED_PORT: OnceLock<u16> = OnceLock::new();
|
||||
static INSTANCE_LOCK: OnceLock<std::fs::File> = OnceLock::new();
|
||||
const PAC_INITIAL_AVAILABLE: bool = false;
|
||||
static PAC_AVAILABLE: AtomicBool = AtomicBool::new(PAC_INITIAL_AVAILABLE);
|
||||
static COMMANDS_READY: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// Implements `global()` using the supplied `OnceCell` static.
|
||||
/// Implements `global()` using the supplied `OnceLock` static.
|
||||
#[macro_export]
|
||||
macro_rules! singleton {
|
||||
($struct_name:ty, $instance_name:ident) => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::{core::handle, utils::resolve::window::build_new_window};
|
||||
use clash_verge_limiter::Limiter;
|
||||
use clash_verge_logging::{Type, logging};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::pin::Pin;
|
||||
use std::sync::LazyLock;
|
||||
use std::time::Duration;
|
||||
use tauri::{Manager as _, WebviewWindow, Wry};
|
||||
|
||||
@@ -26,7 +26,7 @@ pub enum WindowState {
|
||||
}
|
||||
|
||||
const WINDOW_OPERATION_DEBOUNCE_MS: u64 = 625;
|
||||
static WINDOW_OPERATION_LIMITER: Lazy<Limiter> = Lazy::new(|| {
|
||||
static WINDOW_OPERATION_LIMITER: LazyLock<Limiter> = LazyLock::new(|| {
|
||||
Limiter::new(
|
||||
Duration::from_millis(WINDOW_OPERATION_DEBOUNCE_MS),
|
||||
clash_verge_limiter::SystemClock,
|
||||
|
||||
Reference in New Issue
Block a user