Add comment linking engine creating code together
This commit is contained in:
parent
19d19271f6
commit
38f8191ce8
2 changed files with 17 additions and 5 deletions
|
@ -48,7 +48,11 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_engine() -> Engine {
|
/// Creates a default engine for compiling Wasm.
|
||||||
|
/// N.B.: this must create the same `Engine` as
|
||||||
|
/// the `create_default_engine` function
|
||||||
|
/// in `plugin_runtime/src/plugin.rs`.
|
||||||
|
fn create_default_engine() -> Engine {
|
||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
config.async_support(true);
|
config.async_support(true);
|
||||||
// config.epoch_interruption(true);
|
// config.epoch_interruption(true);
|
||||||
|
|
|
@ -64,14 +64,22 @@ pub struct PluginBuilder {
|
||||||
linker: Linker<WasiCtxAlloc>,
|
linker: Linker<WasiCtxAlloc>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a default engine for compiling Wasm.
|
||||||
|
/// N.B.: this must create the same `Engine` as
|
||||||
|
/// the `create_default_engine` function
|
||||||
|
/// in `plugin_runtime/build.rs`.
|
||||||
|
pub fn create_default_engine() -> Result<Engine, Error> {
|
||||||
|
let mut config = Config::default();
|
||||||
|
config.async_support(true);
|
||||||
|
// config.epoch_interruption(true);
|
||||||
|
Engine::new(&config)
|
||||||
|
}
|
||||||
|
|
||||||
impl PluginBuilder {
|
impl PluginBuilder {
|
||||||
/// Create a new [`PluginBuilder`] with the given WASI context.
|
/// Create a new [`PluginBuilder`] with the given WASI context.
|
||||||
/// Using the default context is a safe bet, see [`new_with_default_context`].
|
/// Using the default context is a safe bet, see [`new_with_default_context`].
|
||||||
pub fn new(wasi_ctx: WasiCtx) -> Result<Self, Error> {
|
pub fn new(wasi_ctx: WasiCtx) -> Result<Self, Error> {
|
||||||
let mut config = Config::default();
|
let engine = create_default_engine()?;
|
||||||
config.async_support(true);
|
|
||||||
// config.epoch_interruption(true);
|
|
||||||
let engine = Engine::new(&config)?;
|
|
||||||
let linker = Linker::new(&engine);
|
let linker = Linker::new(&engine);
|
||||||
|
|
||||||
Ok(PluginBuilder {
|
Ok(PluginBuilder {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue