]> git.feebdaed.xyz Git - 0xmirror/tokio.git/commitdiff
runtime: add `thread_park_ok` test (#7402)
authorAlice Ryhl <aliceryhl@google.com>
Mon, 16 Jun 2025 07:49:00 +0000 (09:49 +0200)
committerGitHub <noreply@github.com>
Mon, 16 Jun 2025 07:49:00 +0000 (09:49 +0200)
tokio/tests/rt_handle_block_on.rs

index d62815df9cfeb02a1b6034860b7b89af35779244..b6375ebf0b6973b2925976d10f987596a7b0d654 100644 (file)
@@ -220,6 +220,24 @@ rt_test! {
         assert_eq!(answer, 42);
     }
 
+    #[test]
+    fn thread_park_ok() {
+        use core::task::Poll;
+        let rt = rt();
+        let mut exit = false;
+        rt.handle().block_on(core::future::poll_fn(move |cx| {
+            if exit {
+                return Poll::Ready(());
+            }
+            cx.waker().wake_by_ref();
+            // Verify that consuming the park token does not result in a hang.
+            std::thread::current().unpark();
+            std::thread::park();
+            exit = true;
+            Poll::Pending
+        }));
+    }
+
     // ==== net ======
 
     #[test]