move more deps to cap-std-sync, define own SystemTimeSpec

This commit is contained in:
Pat Hickey
2021-01-21 12:35:55 -08:00
parent 61885b7071
commit fcd00f5de1
13 changed files with 160 additions and 167 deletions

View File

@@ -1,3 +1,4 @@
pub mod clocks;
pub mod dir;
pub mod file;
pub mod sched;
@@ -7,7 +8,7 @@ use cap_rand::RngCore;
use std::cell::RefCell;
use std::path::Path;
use std::rc::Rc;
use wasi_c2::{clocks::WasiClocks, table::Table, Error, WasiCtx, WasiFile};
use wasi_c2::{table::Table, Error, WasiCtx, WasiFile};
pub struct WasiCtxBuilder(wasi_c2::WasiCtxBuilder);
@@ -15,7 +16,7 @@ impl WasiCtxBuilder {
pub fn new() -> Self {
WasiCtxBuilder(WasiCtx::builder(
random(),
clocks(),
clocks::clocks(),
Box::new(sched::SyncSched),
Rc::new(RefCell::new(Table::new())),
))
@@ -51,18 +52,6 @@ impl WasiCtxBuilder {
}
}
pub fn clocks() -> WasiClocks {
let system = Box::new(unsafe { cap_std::time::SystemClock::new() });
let monotonic = unsafe { cap_std::time::MonotonicClock::new() };
let creation_time = monotonic.now();
let monotonic = Box::new(monotonic);
WasiClocks {
system,
monotonic,
creation_time,
}
}
pub fn random() -> RefCell<Box<dyn RngCore>> {
RefCell::new(Box::new(unsafe { cap_rand::rngs::OsRng::default() }))
}