deadpool/managed/
metrics.rs#[cfg(not(target_arch = "wasm32"))]
use std::time::{Duration, Instant};
#[derive(Clone, Copy, Debug)]
#[must_use]
pub struct Metrics {
#[cfg(not(target_arch = "wasm32"))]
pub created: Instant,
#[cfg(not(target_arch = "wasm32"))]
pub recycled: Option<Instant>,
pub recycle_count: usize,
}
impl Metrics {
#[cfg(not(target_arch = "wasm32"))]
pub fn age(&self) -> Duration {
self.created.elapsed()
}
#[cfg(not(target_arch = "wasm32"))]
pub fn last_used(&self) -> Duration {
self.recycled.unwrap_or(self.created).elapsed()
}
}
impl Default for Metrics {
fn default() -> Self {
Self {
#[cfg(not(target_arch = "wasm32"))]
created: Instant::now(),
#[cfg(not(target_arch = "wasm32"))]
recycled: None,
recycle_count: 0,
}
}
}