mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-10-03 12:18:10 +03:00
24 lines
565 B
Rust
24 lines
565 B
Rust
use std::sync::{OnceLock, Mutex};
|
|
|
|
static METRICS: OnceLock<SystemMetrics> = OnceLock::new();
|
|
|
|
pub (crate) struct SystemMetrics {
|
|
pub start_time: Mutex<Option<std::time::Instant>>,
|
|
pub last_poll_time: Mutex<Option<std::time::Instant>>,
|
|
}
|
|
|
|
impl Default for SystemMetrics {
|
|
fn default() -> Self {
|
|
Self {
|
|
start_time: Mutex::new(None),
|
|
last_poll_time: Mutex::new(None),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl SystemMetrics {
|
|
pub fn instance() -> &'static SystemMetrics {
|
|
METRICS.get_or_init(|| SystemMetrics::default())
|
|
}
|
|
}
|