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 system = Box::new(unsafe { SystemClock::new() });
|
||||||
let monotonic = unsafe { cap_std::time::MonotonicClock::new() };
|
let monotonic = unsafe { cap_std::time::MonotonicClock::new() };
|
||||||
let creation_time = monotonic.now();
|
let creation_time = monotonic.now();
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ pub mod file;
|
|||||||
pub mod sched;
|
pub mod sched;
|
||||||
pub mod stdio;
|
pub mod stdio;
|
||||||
|
|
||||||
|
pub use clocks::clocks_ctx;
|
||||||
|
pub use sched::sched_ctx;
|
||||||
|
|
||||||
use cap_rand::RngCore;
|
use cap_rand::RngCore;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -15,9 +18,9 @@ pub struct WasiCtxBuilder(wasi_common::WasiCtxBuilder);
|
|||||||
impl WasiCtxBuilder {
|
impl WasiCtxBuilder {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
WasiCtxBuilder(WasiCtx::builder(
|
WasiCtxBuilder(WasiCtx::builder(
|
||||||
random(),
|
random_ctx(),
|
||||||
clocks::clocks(),
|
clocks_ctx(),
|
||||||
Box::new(sched::SyncSched::new()),
|
sched_ctx(),
|
||||||
Rc::new(RefCell::new(Table::new())),
|
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() }))
|
RefCell::new(Box::new(unsafe { cap_rand::rngs::OsRng::default() }))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,3 +7,9 @@ pub use unix::*;
|
|||||||
mod windows;
|
mod windows;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub use 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