From 92e8a292698f261651fe640510609713b0deed0c Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Wed, 29 Dec 2021 15:21:42 +0100 Subject: cleanup(core): use Extensions to register ops (#13224) In examples and tests --- core/examples/http_bench_json_ops.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'core/examples/http_bench_json_ops.rs') 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 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 { -- cgit v1.2.3