mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-19 13:29:09 +00:00
LazyLock usage
This commit is contained in:
parent
016aaa6128
commit
6567b6bc00
2 changed files with 4 additions and 6 deletions
|
@ -8,7 +8,7 @@ homepage = "https://github.com/blechschmidt/tun2proxy"
|
|||
authors = ["B. Blechschmidt", "ssrlive"]
|
||||
description = "Tunnel interface to proxy"
|
||||
readme = "README.md"
|
||||
rust-version = "1.77"
|
||||
rust-version = "1.80"
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib", "cdylib", "lib"]
|
||||
|
@ -26,7 +26,6 @@ hashlink = "0.9"
|
|||
hickory-proto = "0.24"
|
||||
httparse = "1"
|
||||
ipstack = { version = "0.1" }
|
||||
lazy_static = "1"
|
||||
log = { version = "0.4", features = ["std"] }
|
||||
percent-encoding = "2"
|
||||
socks5-impl = { version = "0.5" }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::error::{Error, Result};
|
||||
use std::os::raw::c_void;
|
||||
use std::sync::{LazyLock, Mutex};
|
||||
|
||||
/// # Safety
|
||||
///
|
||||
|
@ -44,10 +45,8 @@ unsafe impl Sync for TrafficStatusCallback {}
|
|||
static TRAFFIC_STATUS_CALLBACK: std::sync::Mutex<Option<TrafficStatusCallback>> = std::sync::Mutex::new(None);
|
||||
static SEND_INTERVAL_SECS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref TRAFFIC_STATUS: std::sync::Mutex<TrafficStatus> = std::sync::Mutex::new(TrafficStatus::default());
|
||||
static ref TIME_STAMP: std::sync::Mutex<std::time::Instant> = std::sync::Mutex::new(std::time::Instant::now());
|
||||
}
|
||||
static TRAFFIC_STATUS: LazyLock<Mutex<TrafficStatus>> = LazyLock::new(|| Mutex::new(TrafficStatus::default()));
|
||||
static TIME_STAMP: LazyLock<Mutex<std::time::Instant>> = LazyLock::new(|| Mutex::new(std::time::Instant::now()));
|
||||
|
||||
pub(crate) fn traffic_status_update(delta_tx: usize, delta_rx: usize) -> Result<()> {
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue