Support nested block_in_place (#2409)

This commit is contained in:
Jon Gjengset
2020-04-16 16:40:11 -04:00
committed by GitHub
parent 8381dff39b
commit 67c4cc0391
4 changed files with 48 additions and 19 deletions
+20
View File
@@ -27,3 +27,23 @@ async fn basic_blocking() {
assert_eq!(out, "hello");
}
}
#[tokio::test(threaded_scheduler)]
async fn block_in_block() {
// Run a few times
for _ in 0..100 {
let out = assert_ok!(
tokio::spawn(async {
task::block_in_place(|| {
task::block_in_place(|| {
thread::sleep(Duration::from_millis(5));
});
"hello"
})
})
.await
);
assert_eq!(out, "hello");
}
}