cap-std-sync: export ctx components
This commit is contained in:
@@ -33,7 +33,7 @@ impl WasiMonotonicClock for MonotonicClock {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clocks() -> WasiClocks {
|
||||
pub fn clocks_ctx() -> WasiClocks {
|
||||
let system = Box::new(unsafe { SystemClock::new() });
|
||||
let monotonic = unsafe { cap_std::time::MonotonicClock::new() };
|
||||
let creation_time = monotonic.now();
|
||||
|
||||
@@ -4,6 +4,9 @@ pub mod file;
|
||||
pub mod sched;
|
||||
pub mod stdio;
|
||||
|
||||
pub use clocks::clocks_ctx;
|
||||
pub use sched::sched_ctx;
|
||||
|
||||
use cap_rand::RngCore;
|
||||
use std::cell::RefCell;
|
||||
use std::path::Path;
|
||||
@@ -15,9 +18,9 @@ pub struct WasiCtxBuilder(wasi_common::WasiCtxBuilder);
|
||||
impl WasiCtxBuilder {
|
||||
pub fn new() -> Self {
|
||||
WasiCtxBuilder(WasiCtx::builder(
|
||||
random(),
|
||||
clocks::clocks(),
|
||||
Box::new(sched::SyncSched::new()),
|
||||
random_ctx(),
|
||||
clocks_ctx(),
|
||||
sched_ctx(),
|
||||
Rc::new(RefCell::new(Table::new())),
|
||||
))
|
||||
}
|
||||
@@ -91,6 +94,6 @@ impl WasiCtxBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn random() -> RefCell<Box<dyn RngCore>> {
|
||||
pub fn random_ctx() -> RefCell<Box<dyn RngCore>> {
|
||||
RefCell::new(Box::new(unsafe { cap_rand::rngs::OsRng::default() }))
|
||||
}
|
||||
|
||||
@@ -7,3 +7,9 @@ pub use unix::*;
|
||||
mod windows;
|
||||
#[cfg(windows)]
|
||||
pub use windows::*;
|
||||
|
||||
use wasi_common::sched::WasiSched;
|
||||
|
||||
pub fn sched_ctx() -> Box<dyn WasiSched> {
|
||||
Box::new(SyncSched::new())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user