Sha256: 3d57d08385df1b1751c96b0d38e6d07f0f4e938cf03ea3776694afc403124954

Contents?: true

Size: 823 Bytes

Versions: 14

Compression:

Stored size: 823 Bytes

Contents

#[cfg(unix)]
pub mod unix;
#[cfg(unix)]
pub use unix::poll_oneoff;

#[cfg(windows)]
pub mod windows;
#[cfg(windows)]
pub use windows::poll_oneoff;

use crate::{
    sched::{Poll, WasiSched},
    Error,
};
use std::thread;
use std::time::Duration;

pub struct SyncSched {}
impl SyncSched {
    pub fn new() -> Self {
        Self {}
    }
}
#[wiggle::async_trait]
impl WasiSched for SyncSched {
    async fn poll_oneoff<'a>(&self, poll: &mut Poll<'a>) -> Result<(), Error> {
        poll_oneoff(poll).await
    }
    async fn sched_yield(&self) -> Result<(), Error> {
        thread::yield_now();
        Ok(())
    }
    async fn sleep(&self, duration: Duration) -> Result<(), Error> {
        std::thread::sleep(duration);
        Ok(())
    }
}
pub fn sched_ctx() -> Box<dyn WasiSched> {
    Box::new(SyncSched::new())
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/wasi-common-29.0.0/src/sync/sched.rs
wasmtime-28.0.0 ./ext/cargo-vendor/wasi-common-28.0.0/src/sync/sched.rs
wasmtime-27.0.0 ./ext/cargo-vendor/wasi-common-27.0.0/src/sync/sched.rs
wasmtime-26.0.0 ./ext/cargo-vendor/wasi-common-26.0.0/src/sync/sched.rs
wasmtime-25.0.2 ./ext/cargo-vendor/wasi-common-25.0.2/src/sync/sched.rs
wasmtime-25.0.1 ./ext/cargo-vendor/wasi-common-25.0.1/src/sync/sched.rs
wasmtime-25.0.0 ./ext/cargo-vendor/wasi-common-25.0.0/src/sync/sched.rs
wasmtime-24.0.0 ./ext/cargo-vendor/wasi-common-24.0.0/src/sync/sched.rs
wasmtime-23.0.2 ./ext/cargo-vendor/wasi-common-23.0.2/src/sync/sched.rs
wasmtime-22.0.0 ./ext/cargo-vendor/wasi-common-22.0.0/src/sync/sched.rs
wasmtime-21.0.1 ./ext/cargo-vendor/wasi-common-21.0.1/src/sync/sched.rs
wasmtime-20.0.2 ./ext/cargo-vendor/wasi-common-20.0.2/src/sync/sched.rs
wasmtime-20.0.0 ./ext/cargo-vendor/wasi-common-20.0.0/src/sync/sched.rs
wasmtime-18.0.3 ./ext/cargo-vendor/wasi-common-18.0.3/src/sync/sched.rs