1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#[cfg(test)] pub(super) type TestHook = std::sync::Arc<dyn Fn() + Send + Sync + 'static>; #[cfg(test)] pub(super) static STEER_READ_LOCK_HOOK: std::sync::OnceLock<std::sync::Mutex<Option<TestHook>>> = std::sync::OnceLock::new(); #[cfg(test)] pub(super) static STEER_REBUILD_SWAP_HOOK: std::sync::OnceLock<std::sync::Mutex<Option<TestHook>>> = std::sync::OnceLock::new(); #[cfg(test)] pub(super) fn call_steer_read_lock_hook() { let hook = STEER_READ_LOCK_HOOK .get_or_init(|| std::sync::Mutex::new(None)) .lock() .expect("steer read hook lock poisoned") .clone(); if let Some(hook) = hook { hook(); } } #[cfg(not(test))] pub(super) fn call_steer_read_lock_hook() {} #[cfg(test)] pub(super) fn call_steer_rebuild_swap_hook() { let hook = STEER_REBUILD_SWAP_HOOK .get_or_init(|| std::sync::Mutex::new(None)) .lock() .expect("steer rebuild hook lock poisoned") .clone(); if let Some(hook) = hook { hook(); } } #[cfg(not(test))] pub(super) fn call_steer_rebuild_swap_hook() {}