mirror of https://github.com/MingweiSamuel/Riven
parent
648602a4b6
commit
f4c75a421a
|
@ -41,3 +41,24 @@ impl Notify {
|
||||||
self.waiters.lock().drain(..).for_each(Waker::wake);
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue