summaryrefslogtreecommitdiffstats
path: root/tokio/tests
diff options
context:
space:
mode:
authorLucio Franco <luciofranco14@gmail.com>2020-09-23 14:35:10 -0400
committerGitHub <noreply@github.com>2020-09-23 14:35:10 -0400
commitf25f12d57638a2928b3f738b3b1392d8773e276e (patch)
tree04da3ba7022a42bf8d1d08a039fcc1fc2fc95313 /tokio/tests
parent0f70530ee7cda68b68f2f8131b5866cfa937ee1f (diff)
rt: Allow concurrent `block_on`'s with basic_scheduler (#2804)
Diffstat (limited to 'tokio/tests')
-rw-r--r--tokio/tests/rt_common.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tokio/tests/rt_common.rs b/tokio/tests/rt_common.rs
index 35e2ea81..a8968be1 100644
--- a/tokio/tests/rt_common.rs
+++ b/tokio/tests/rt_common.rs
@@ -575,6 +575,38 @@ rt_test! {
}
#[test]
+ fn always_active_parker() {
+ // This test it to show that we will always have
+ // an active parker even if we call block_on concurrently
+
+ let rt = rt();
+ let rt2 = rt.clone();
+
+ let (tx1, rx1) = oneshot::channel();
+ let (tx2, rx2) = oneshot::channel();
+
+ let jh1 = thread::spawn(move || {
+ rt.block_on(async move {
+ rx2.await.unwrap();
+ time::delay_for(Duration::from_millis(5)).await;
+ tx1.send(()).unwrap();
+ });
+ });
+
+ let jh2 = thread::spawn(move || {
+ rt2.block_on(async move {
+ tx2.send(()).unwrap();
+ time::delay_for(Duration::from_millis(5)).await;
+ rx1.await.unwrap();
+ time::delay_for(Duration::from_millis(5)).await;
+ });
+ });
+
+ jh1.join().unwrap();
+ jh2.join().unwrap();
+ }
+
+ #[test]
// IOCP requires setting the "max thread" concurrency value. The sane,
// default, is to set this to the number of cores. Threads that poll I/O
// become associated with the IOCP handle. Once those threads sleep for any