Add a sleep function to the WasiSched trait.

This commit is contained in:
Dan Gohman
2021-03-22 11:23:45 -07:00
parent dd7e16762c
commit 2880dab8f8
5 changed files with 32 additions and 2 deletions

View File

@@ -16,7 +16,6 @@ use std::cell::{Ref, RefMut};
use std::convert::{TryFrom, TryInto};
use std::io::{IoSlice, IoSliceMut};
use std::ops::{Deref, DerefMut};
use std::thread;
use tracing::debug;
use wiggle::GuestPtr;
@@ -921,7 +920,7 @@ impl<'a> wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx {
.flags
.contains(types::Subclockflags::SUBSCRIPTION_CLOCK_ABSTIME)
{
thread::sleep(Duration::from_nanos(clocksub.timeout));
self.sched.sleep(Duration::from_nanos(clocksub.timeout));
events.write(types::Event {
userdata: sub.userdata,