Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test block_in_place followed by Pending #2120

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions tokio/src/runtime/thread_pool/tests/loom_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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));

Expand All @@ -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 {
Expand All @@ -93,6 +107,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(|| {
Expand Down