summaryrefslogtreecommitdiffstats
path: root/tokio/src/runtime/thread_pool
diff options
context:
space:
mode:
authorJon Gjengset <jon@thesquareplanet.com>2020-01-24 18:08:30 -0500
committerCarl Lerche <me@carllerche.com>2020-01-24 15:08:30 -0800
commita16c9a5a018af21ce48895207564a74c7feacc8b (patch)
tree5eb24b57d4e0f45598eb4e297bfa2209d71b0a56 /tokio/src/runtime/thread_pool
parentf0bfebb7e1b1b7e86857781a6d730679b9761daf (diff)
rt: test block_in_place followed by Pending (#2120)
Diffstat (limited to 'tokio/src/runtime/thread_pool')
-rw-r--r--tokio/src/runtime/thread_pool/tests/loom_pool.rs38
1 files changed, 31 insertions, 7 deletions
diff --git a/tokio/src/runtime/thread_pool/tests/loom_pool.rs b/tokio/src/runtime/thread_pool/tests/loom_pool.rs
index 0394db16..3151eaa6 100644
--- a/tokio/src/runtime/thread_pool/tests/loom_pool.rs
+++ b/tokio/src/runtime/thread_pool/tests/loom_pool.rs
@@ -41,16 +41,18 @@ fn pool_multi_spawn() {
});
}
-#[test]
-fn only_blocking() {
- loom::model(|| {
+fn only_blocking_inner(first_pending: bool) {
+ loom::model(move || {
let pool = mk_pool(1);
let (block_tx, block_rx) = oneshot::channel();
pool.spawn(async move {
crate::task::block_in_place(move || {
block_tx.send(());
- })
+ });
+ if first_pending {
+ yield_once().await
+ }
});
block_rx.recv();
@@ -59,9 +61,18 @@ fn only_blocking() {
}
#[test]
-fn blocking_and_regular() {
+fn only_blocking() {
+ only_blocking_inner(false)
+}
+
+#[test]
+fn only_blocking_with_pending() {
+ only_blocking_inner(true)
+}
+
+fn blocking_and_regular_inner(first_pending: bool) {
const NUM: usize = 3;
- loom::model(|| {
+ loom::model(move || {
let pool = mk_pool(1);
let cnt = Arc::new(AtomicUsize::new(0));
@@ -72,7 +83,10 @@ fn blocking_and_regular() {
pool.spawn(async move {
crate::task::block_in_place(move || {
block_tx.send(());
- })
+ });
+ if first_pending {
+ yield_once().await
+ }
});
for _ in 0..NUM {
@@ -94,6 +108,16 @@ fn blocking_and_regular() {
}
#[test]
+fn blocking_and_regular() {
+ blocking_and_regular_inner(false);
+}
+
+#[test]
+fn blocking_and_regular_with_pending() {
+ blocking_and_regular_inner(true);
+}
+
+#[test]
fn pool_multi_notify() {
loom::model(|| {
let pool = mk_pool(2);