Merge pull request #2756 from bytecodealliance/pch/wasi_sleep_fallible
wasi: make WasiSched::sleep fallible
This commit is contained in:
@@ -108,8 +108,9 @@ impl WasiSched for SyncSched {
|
||||
std::thread::yield_now();
|
||||
Ok(())
|
||||
}
|
||||
fn sleep(&self, duration: Duration) {
|
||||
std::thread::sleep(duration)
|
||||
fn sleep(&self, duration: Duration) -> Result<(), Error> {
|
||||
std::thread::sleep(duration);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,8 +128,9 @@ impl WasiSched for SyncSched {
|
||||
thread::yield_now();
|
||||
Ok(())
|
||||
}
|
||||
fn sleep(&self, duration: Duration) {
|
||||
std::thread::sleep(duration)
|
||||
fn sleep(&self, duration: Duration) -> Result<(), Error> {
|
||||
std::thread::sleep(duration);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use subscription::{MonotonicClockSubscription, RwSubscription, Subscription, Sub
|
||||
pub trait WasiSched {
|
||||
fn poll_oneoff(&self, poll: &Poll) -> Result<(), Error>;
|
||||
fn sched_yield(&self) -> Result<(), Error>;
|
||||
fn sleep(&self, duration: Duration);
|
||||
fn sleep(&self, duration: Duration) -> Result<(), Error>;
|
||||
}
|
||||
|
||||
pub struct Userdata(u64);
|
||||
|
||||
@@ -749,8 +749,7 @@ impl<'a> wasi_unstable::WasiUnstable for WasiCtx {
|
||||
.flags
|
||||
.contains(types::Subclockflags::SUBSCRIPTION_CLOCK_ABSTIME)
|
||||
{
|
||||
self.sched.sleep(Duration::from_nanos(clocksub.timeout));
|
||||
|
||||
self.sched.sleep(Duration::from_nanos(clocksub.timeout))?;
|
||||
events.write(types::Event {
|
||||
userdata: sub.userdata,
|
||||
error: types::Errno::Success,
|
||||
|
||||
@@ -920,8 +920,7 @@ impl<'a> wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx {
|
||||
.flags
|
||||
.contains(types::Subclockflags::SUBSCRIPTION_CLOCK_ABSTIME)
|
||||
{
|
||||
self.sched.sleep(Duration::from_nanos(clocksub.timeout));
|
||||
|
||||
self.sched.sleep(Duration::from_nanos(clocksub.timeout))?;
|
||||
events.write(types::Event {
|
||||
userdata: sub.userdata,
|
||||
error: types::Errno::Success,
|
||||
|
||||
Reference in New Issue
Block a user