diff options
Diffstat (limited to 'core/examples/http_bench_json_ops.rs')
-rw-r--r-- | core/examples/http_bench_json_ops.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/core/examples/http_bench_json_ops.rs b/core/examples/http_bench_json_ops.rs index 641483b0b..f1dfb1039 100644 --- a/core/examples/http_bench_json_ops.rs +++ b/core/examples/http_bench_json_ops.rs @@ -118,11 +118,17 @@ impl From<tokio::net::TcpStream> for TcpStream { } fn create_js_runtime() -> JsRuntime { - let mut runtime = JsRuntime::new(Default::default()); - runtime.register_op("listen", deno_core::op_sync(op_listen)); - runtime.register_op("accept", deno_core::op_async(op_accept)); - runtime.sync_ops_cache(); - runtime + let ext = deno_core::Extension::builder() + .ops(vec![ + ("listen", deno_core::op_sync(op_listen)), + ("accept", deno_core::op_async(op_accept)), + ]) + .build(); + + JsRuntime::new(deno_core::RuntimeOptions { + extensions: vec![ext], + ..Default::default() + }) } fn op_listen(state: &mut OpState, _: (), _: ()) -> Result<ResourceId, Error> { |