From d3aadaee5fbfe46daa66ca8d8aff924d356858d8 Mon Sep 17 00:00:00 2001 From: Wing Ho Tang <47057684+tombelieber@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:02:35 +0800 Subject: [PATCH] feat: add resource clean up and warm up --- examples/o1_synchronizer_market_data.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/o1_synchronizer_market_data.rs b/examples/o1_synchronizer_market_data.rs index 5cef799..720a16b 100644 --- a/examples/o1_synchronizer_market_data.rs +++ b/examples/o1_synchronizer_market_data.rs @@ -155,6 +155,15 @@ fn main() { // `shm_path` is now a PathBuf let shm_path = Arc::new(shm_path); // Arc + // 在 main 开头清理旧共享内存: +let _ = fs::remove_file(&*shm_path); + +// 添加预热迭代(不记录延迟): +for _ in 0..1000 { + synchronizer.write(&data, ...).unwrap(); +} + + // Add a shared 'done' flag so readers can stop let done_flag = Arc::new(AtomicBool::new(false));