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