use std::cell::RefCell;
use std::collections::HashMap;
use crate::reactive::SignalId;
use super::ring;
thread_local! {
static LAST_CHANGED: RefCell<HashMap<SignalId, f64>> =
RefCell::new(HashMap::new());
}
pub(super) fn record(id: SignalId) {
let t = ring::now_ms_for_scope();
LAST_CHANGED.with(|m| {
m.borrow_mut().insert(id, t);
});
}
#[allow(dead_code)] pub(super) fn get(id: SignalId) -> Option<f64> {
LAST_CHANGED.with(|m| m.borrow().get(&id).copied())
}
#[allow(dead_code)] pub(super) fn snapshot() -> HashMap<SignalId, f64> {
LAST_CHANGED.with(|m| m.borrow().clone())
}