summaryrefslogtreecommitdiff
path: root/core/examples/http_bench_json_ops.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-12-29 15:21:42 +0100
committerGitHub <noreply@github.com>2021-12-29 15:21:42 +0100
commit92e8a292698f261651fe640510609713b0deed0c (patch)
treed81b227339ca699f534467bf5a6d2118a8dfbe5b /core/examples/http_bench_json_ops.rs
parentb33bbf6af5749edb5d5e2e8de3b8d91416a29684 (diff)
cleanup(core): use Extensions to register ops (#13224)
In examples and tests
Diffstat (limited to 'core/examples/http_bench_json_ops.rs')
-rw-r--r--core/examples/http_bench_json_ops.rs16
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> {