Sha256: c5e9111a9bfabc389bc7d92e879b045fdec201f2d24532d1899e96ecda56ede9
Contents?: true
Size: 834 Bytes
Versions: 24
Compression:
Stored size: 834 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 std::thread; use std::time::Duration; use wasi_common::{ sched::{Poll, WasiSched}, Error, }; pub struct SyncSched {} impl SyncSched { pub fn new() -> Self { Self {} } } #[async_trait::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
24 entries across 24 versions & 1 rubygems