cap-std-sync: async-trait e-paperwork
This commit is contained in:
@@ -13,6 +13,7 @@ include = ["src/**/*", "LICENSE" ]
|
||||
|
||||
[dependencies]
|
||||
wasi-common = { path = "../", version = "0.26.0" }
|
||||
wiggle = { path = "../../wiggle", version = "0.26.0" }
|
||||
anyhow = "1.0"
|
||||
cap-std = "0.13.7"
|
||||
cap-fs-ext = "0.13.7"
|
||||
|
||||
@@ -21,8 +21,9 @@ impl SyncSched {
|
||||
}
|
||||
}
|
||||
|
||||
#[wiggle::async_trait]
|
||||
impl WasiSched for SyncSched {
|
||||
fn poll_oneoff<'a>(&self, poll: &'a Poll<'a>) -> Result<(), Error> {
|
||||
async fn poll_oneoff<'a>(&self, poll: &'_ Poll<'a>) -> Result<(), Error> {
|
||||
if poll.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
@@ -104,11 +105,11 @@ impl WasiSched for SyncSched {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn sched_yield(&self) -> Result<(), Error> {
|
||||
async fn sched_yield(&self) -> Result<(), Error> {
|
||||
std::thread::yield_now();
|
||||
Ok(())
|
||||
}
|
||||
fn sleep(&self, duration: Duration) -> Result<(), Error> {
|
||||
async fn sleep(&self, duration: Duration) -> Result<(), Error> {
|
||||
std::thread::sleep(duration);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ impl SyncSched {
|
||||
}
|
||||
}
|
||||
|
||||
#[wiggle::async_trait]
|
||||
impl WasiSched for SyncSched {
|
||||
fn poll_oneoff<'a>(&self, poll: &'a Poll<'a>) -> Result<(), Error> {
|
||||
async fn poll_oneoff<'a>(&self, poll: &'_ Poll<'a>) -> Result<(), Error> {
|
||||
if poll.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
@@ -124,11 +125,11 @@ impl WasiSched for SyncSched {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
fn sched_yield(&self) -> Result<(), Error> {
|
||||
async fn sched_yield(&self) -> Result<(), Error> {
|
||||
thread::yield_now();
|
||||
Ok(())
|
||||
}
|
||||
fn sleep(&self, duration: Duration) -> Result<(), Error> {
|
||||
async fn sleep(&self, duration: Duration) -> Result<(), Error> {
|
||||
std::thread::sleep(duration);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user