Skip to content

Commit

Permalink
Fix test.
Browse files Browse the repository at this point in the history
  • Loading branch information
futursolo committed Aug 29, 2022
1 parent f310575 commit e18e0fd
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/yew/src/platform/rt_tokio/mod.rs
Expand Up @@ -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;

Expand All @@ -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!");
});
Expand Down

0 comments on commit e18e0fd

Please sign in to comment.