cap-std-sync: export ctx components

This commit is contained in:
Pat Hickey
2021-01-30 13:38:44 -08:00
parent e940d31f95
commit b6cd7d84ad
3 changed files with 14 additions and 5 deletions

View File

@@ -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() }))
}