Path: blob/main/crates/wasi-common/src/tokio/sched.rs
1692 views
#[cfg(unix)]1mod unix;2#[cfg(unix)]3pub use unix::poll_oneoff;45#[cfg(windows)]6mod windows;7#[cfg(windows)]8pub use windows::poll_oneoff;910use crate::{11Error,12sched::{Duration, Poll, WasiSched},13};1415pub fn sched_ctx() -> Box<dyn crate::WasiSched> {16struct AsyncSched;1718#[wiggle::async_trait]19impl WasiSched for AsyncSched {20async fn poll_oneoff<'a>(&self, poll: &mut Poll<'a>) -> Result<(), Error> {21poll_oneoff(poll).await22}23async fn sched_yield(&self) -> Result<(), Error> {24tokio::task::yield_now().await;25Ok(())26}27async fn sleep(&self, duration: Duration) -> Result<(), Error> {28tokio::time::sleep(duration).await;29Ok(())30}31}3233Box::new(AsyncSched)34}353637