Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
futursolo committed Sep 4, 2022
1 parent 2a300fe commit a78f0b3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/yew/src/platform/rt_tokio/mod.rs
Expand Up @@ -112,31 +112,33 @@ mod tests {
use std::time::Duration;

use futures::channel::oneshot;
use once_cell::sync::Lazy;
use tokio::sync::Barrier;
use tokio::test;
use tokio::time::timeout;

use super::*;

static RUNTIME_2: Lazy<Runtime> =
Lazy::new(|| Runtime::new(2).expect("failed to create runtime."));

#[test]
async fn test_spawn_pinned_least_busy() {
let runtime = Runtime::new(2).expect("failed to create runtime.");

let (tx1, rx1) = oneshot::channel();
let (tx2, rx2) = oneshot::channel();

let bar = Arc::new(Barrier::new(2));

{
let bar = bar.clone();
runtime.spawn_pinned(move || async move {
RUNTIME_2.spawn_pinned(move || async move {
bar.wait().await;
tx1.send(std::thread::current().id())
.expect("failed to send!");
});
}

runtime.spawn_pinned(move || async move {
RUNTIME_2.spawn_pinned(move || async move {
bar.wait().await;
tx2.send(std::thread::current().id())
.expect("failed to send!");
Expand All @@ -157,7 +159,7 @@ mod tests {

#[test]
async fn test_spawn_local_within_send() {
let runtime = Runtime::new(1).expect("failed to create runtime.");
let runtime = Runtime::default();

let (tx, rx) = oneshot::channel();

Expand Down

0 comments on commit a78f0b3

Please sign in to comment.