From e18e0fdcbc6e32df565a99233a77411f50417ea1 Mon Sep 17 00:00:00 2001 From: Kaede Hoshikawa Date: Mon, 29 Aug 2022 19:26:07 +0900 Subject: [PATCH] Fix test. --- packages/yew/src/platform/rt_tokio/mod.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/yew/src/platform/rt_tokio/mod.rs b/packages/yew/src/platform/rt_tokio/mod.rs index 6be2c92b0aa..9ad07917463 100644 --- a/packages/yew/src/platform/rt_tokio/mod.rs +++ b/packages/yew/src/platform/rt_tokio/mod.rs @@ -108,9 +108,11 @@ impl Runtime { #[cfg(test)] mod tests { + use std::sync::Arc; use std::time::Duration; use futures::channel::oneshot; + use tokio::sync::Barrier; use tokio::test; use tokio::time::timeout; @@ -123,12 +125,19 @@ mod tests { let (tx1, rx1) = oneshot::channel(); let (tx2, rx2) = oneshot::channel(); - runtime.spawn_pinned(move || async move { - tx1.send(std::thread::current().id()) - .expect("failed to send!"); - }); + let bar = Arc::new(Barrier::new(2)); + + { + let bar = bar.clone(); + runtime.spawn_pinned(move || async move { + bar.wait().await; + tx1.send(std::thread::current().id()) + .expect("failed to send!"); + }); + } runtime.spawn_pinned(move || async move { + bar.wait().await; tx2.send(std::thread::current().id()) .expect("failed to send!"); });