Sha256: eec0f029e9e536ba4e56a4ba1a1d1b519e3946c5bb6e6324ab87f60bb1a04194

Contents?: true

Size: 849 Bytes

Versions: 8

Compression:

Stored size: 849 Bytes

Contents

use crate::runtime::park;
use crate::runtime::{self, Runtime};

#[test]
fn yield_calls_park_before_scheduling_again() {
    // Don't need to check all permutations
    let mut loom = loom::model::Builder::default();
    loom.max_permutations = Some(1);
    loom.check(|| {
        let rt = mk_runtime();

        let jh = rt.spawn(async {
            let tid = loom::thread::current().id();
            let park_count = park::current_thread_park_count();

            crate::task::yield_now().await;

            if tid == loom::thread::current().id() {
                let new_park_count = park::current_thread_park_count();
                assert_eq!(park_count + 1, new_park_count);
            }
        });

        rt.block_on(jh).unwrap();
    });
}

fn mk_runtime() -> Runtime {
    runtime::Builder::new_current_thread().build().unwrap()
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/runtime/tests/loom_current_thread/yield_now.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/runtime/tests/loom_current_thread/yield_now.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/src/runtime/tests/loom_current_thread/yield_now.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/src/runtime/tests/loom_current_thread/yield_now.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tokio-1.40.0/src/runtime/tests/loom_current_thread/yield_now.rs
wasmtime-25.0.1 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/tests/loom_current_thread/yield_now.rs
wasmtime-25.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/tests/loom_current_thread/yield_now.rs
wasmtime-24.0.0 ./ext/cargo-vendor/tokio-1.39.3/src/runtime/tests/loom_current_thread/yield_now.rs