diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-09-11 15:18:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-11 15:18:49 +0200 |
commit | 0d1f626edd7c574ff0e70438cdb678dcb5c91170 (patch) | |
tree | 8d80e4f32ba9535da4c387234b795385ee2f6492 /core/examples/http_bench_json_ops.rs | |
parent | 7c2e7c660804afca823d60e6496aa853f75db16c (diff) |
refactor(core): JsRuntime initialization (#7415)
Removes:
- "deno_core::StartupData"
- "deno_core::Script"
- "deno_core::OwnedScript"
Changes to "JsRuntime":
- remove "new_with_loader()"
- remove "with_heap_limits()"
- rename "IsolateOptions" to "RuntimeOptions" and make public
- "JsRuntime::new()" takes "RuntimeOptions" as a single param
Diffstat (limited to 'core/examples/http_bench_json_ops.rs')
-rw-r--r-- | core/examples/http_bench_json_ops.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs index dc0c837e2..a7db450e4 100644 --- a/core/examples/http_bench_json_ops.rs +++ b/core/examples/http_bench_json_ops.rs @@ -6,8 +6,6 @@ use deno_core::BufVec; use deno_core::ErrBox; use deno_core::JsRuntime; use deno_core::OpState; -use deno_core::Script; -use deno_core::StartupData; use deno_core::ZeroCopyBuf; use futures::future::poll_fn; use futures::future::Future; @@ -42,11 +40,7 @@ impl log::Log for Logger { } fn create_isolate() -> JsRuntime { - let startup_data = StartupData::Script(Script { - source: include_str!("http_bench_json_ops.js"), - filename: "http_bench_json_ops.js", - }); - let mut runtime = JsRuntime::new(startup_data, false); + let mut runtime = JsRuntime::new(Default::default()); runtime.register_op("listen", deno_core::json_op_sync(op_listen)); runtime.register_op("close", deno_core::json_op_sync(op_close)); runtime.register_op("accept", deno_core::json_op_async(op_accept)); @@ -183,11 +177,21 @@ fn main() { // NOTE: `--help` arg will display V8 help and exit deno_core::v8_set_flags(env::args().collect()); - let isolate = create_isolate(); + let mut isolate = create_isolate(); let mut runtime = runtime::Builder::new() .basic_scheduler() .enable_all() .build() .unwrap(); - js_check(runtime.block_on(isolate)); + + let future = async move { + isolate + .execute( + "http_bench_json_ops.js", + include_str!("http_bench_json_ops.js"), + ) + .unwrap(); + isolate.await + }; + js_check(runtime.block_on(future)); } |