From 67ccbf9b0e9ea0e3bf6b6e8b78ff1c14db693c79 Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Sun, 4 Apr 2021 19:29:27 +0200 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Alice Ryhl --- tokio/tests/task_abort.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tokio/tests/task_abort.rs b/tokio/tests/task_abort.rs index 05b59022a48..0458e4ceed9 100644 --- a/tokio/tests/task_abort.rs +++ b/tokio/tests/task_abort.rs @@ -43,7 +43,6 @@ fn test_abort_without_panic_3662() { } let rt = tokio::runtime::Builder::new_current_thread() - .worker_threads(1) .build() .unwrap(); @@ -55,12 +54,12 @@ fn test_abort_without_panic_3662() { // NB: just grab the drop check here so that it becomes part of the // task. let _drop_check = drop_check; - futures::future::pending::<()>().await; + std::future::pending::<()>().await; }); let drop_flag2 = drop_flag.clone(); - let task = tokio::task::spawn_blocking(move || { + let task = std::thread::spawn(move || { // This runs in a separate thread so it doesn't have immediate // thread-local access to the executor. It does however transition // the underlying task to be completed, which will cause it to be @@ -87,16 +86,7 @@ fn test_abort_without_panic_3662() { // so that the scheduler can go into the "auxilliary tasks" mode, at // which point the task is removed from the scheduler. let i = tokio::spawn(async move { - let mut first = true; - - let task = futures::future::poll_fn(|cx| { - if std::mem::take(&mut first) { - cx.waker().wake_by_ref(); - Poll::Pending - } else { - Poll::Ready(()) - } - }); + tokio::task::yield_now().await; task.await; });