mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
In lqosd, replace lazy_static with once_cell, per Rust best practices
These days the Rust team are recommending "once_cell", which has simpler syntax and does the same thing.
This commit is contained in:
2
src/rust/Cargo.lock
generated
2
src/rust/Cargo.lock
generated
@@ -1436,7 +1436,6 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"jemallocator",
|
"jemallocator",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"lqos_bus",
|
"lqos_bus",
|
||||||
"lqos_config",
|
"lqos_config",
|
||||||
@@ -1444,6 +1443,7 @@ dependencies = [
|
|||||||
"lqos_sys",
|
"lqos_sys",
|
||||||
"lqos_utils",
|
"lqos_utils",
|
||||||
"nix",
|
"nix",
|
||||||
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"rayon",
|
"rayon",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ lqos_sys = { path = "../lqos_sys" }
|
|||||||
lqos_queue_tracker = { path = "../lqos_queue_tracker" }
|
lqos_queue_tracker = { path = "../lqos_queue_tracker" }
|
||||||
lqos_utils = { path = "../lqos_utils" }
|
lqos_utils = { path = "../lqos_utils" }
|
||||||
tokio = { version = "1", features = [ "full", "parking_lot" ] }
|
tokio = { version = "1", features = [ "full", "parking_lot" ] }
|
||||||
lazy_static = "1.4"
|
once_cell = "1.17.1"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
lqos_bus = { path = "../lqos_bus" }
|
lqos_bus = { path = "../lqos_bus" }
|
||||||
signal-hook = "0.3"
|
signal-hook = "0.3"
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
mod throughput_entry;
|
mod throughput_entry;
|
||||||
mod tracking_data;
|
mod tracking_data;
|
||||||
use crate::throughput_tracker::tracking_data::ThroughputTracker;
|
use crate::throughput_tracker::tracking_data::ThroughputTracker;
|
||||||
use lazy_static::*;
|
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use lqos_bus::{BusResponse, IpStats, TcHandle, XdpPpingResult};
|
use lqos_bus::{BusResponse, IpStats, TcHandle, XdpPpingResult};
|
||||||
use lqos_sys::XdpIpAddress;
|
use lqos_sys::XdpIpAddress;
|
||||||
use lqos_utils::{fdtimer::periodic, unix_time::time_since_boot};
|
use lqos_utils::{fdtimer::periodic, unix_time::time_since_boot};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
const RETIRE_AFTER_SECONDS: u64 = 30;
|
const RETIRE_AFTER_SECONDS: u64 = 30;
|
||||||
|
|
||||||
lazy_static! {
|
static THROUGHPUT_TRACKER: Lazy<RwLock<ThroughputTracker>> = Lazy::new(|| RwLock::new(ThroughputTracker::new()));
|
||||||
static ref THROUGHPUT_TRACKER: RwLock<ThroughputTracker> =
|
|
||||||
RwLock::new(ThroughputTracker::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn spawn_throughput_monitor() {
|
pub fn spawn_throughput_monitor() {
|
||||||
info!("Starting the bandwidth monitor thread.");
|
info!("Starting the bandwidth monitor thread.");
|
||||||
|
|||||||
Reference in New Issue
Block a user