From f4c75a421a7e126222240df4fa14d13f0062d692 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Tue, 26 Mar 2024 10:01:11 -0700 Subject: [PATCH] test: add `Notify` memory leak test (failing) ref #67 --- riven/src/util/notify.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/riven/src/util/notify.rs b/riven/src/util/notify.rs index 82d4af6..f75d065 100644 --- a/riven/src/util/notify.rs +++ b/riven/src/util/notify.rs @@ -41,3 +41,24 @@ impl Notify { self.waiters.lock().drain(..).for_each(Waker::wake); } } + +#[cfg(all(test, not(target_family = "wasm")))] +mod test { + use futures::FutureExt; + + use super::*; + + #[tokio::test] + async fn memory_leak() { + let notify = Notify::new(); + + for _ in 0..100 { + futures::select_biased! { + _ = notify.notified().fuse() => {} + _ = tokio::task::yield_now().fuse() => {} + } + } + + assert_eq!(0, notify.waiters.lock().len()); + } +}