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_bin_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_bin_ops.rs')
-rw-r--r-- | core/examples/http_bench_bin_ops.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/core/examples/http_bench_bin_ops.rs b/core/examples/http_bench_bin_ops.rs index b29af8b9d..2748705ea 100644 --- a/core/examples/http_bench_bin_ops.rs +++ b/core/examples/http_bench_bin_ops.rs @@ -6,8 +6,6 @@ use deno_core::BufVec; use deno_core::JsRuntime; use deno_core::Op; use deno_core::OpState; -use deno_core::Script; -use deno_core::StartupData; use deno_core::ZeroCopyBuf; use futures::future::poll_fn; use futures::future::FutureExt; @@ -78,12 +76,7 @@ impl From<Record> for RecordBuf { } fn create_isolate() -> JsRuntime { - let startup_data = StartupData::Script(Script { - source: include_str!("http_bench_bin_ops.js"), - filename: "http_bench_bin_ops.js", - }); - - let mut isolate = JsRuntime::new(startup_data, false); + let mut isolate = JsRuntime::new(Default::default()); register_op_bin_sync(&mut isolate, "listen", op_listen); register_op_bin_sync(&mut isolate, "close", op_close); register_op_bin_async(&mut isolate, "accept", op_accept); @@ -252,13 +245,23 @@ 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_bin_ops.js", + include_str!("http_bench_bin_ops.js"), + ) + .unwrap(); + isolate.await + }; + js_check(runtime.block_on(future)); } #[test] |