From 8e84dc0139055db8c84ad28723114d343982a8f7 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Wed, 31 May 2023 08:19:06 -0600 Subject: chore(core): Split JsRuntimeForSnapshot from JsRuntime (#19308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This cleans up `JsRuntime` a bit more: * We no longer print cargo's rerun-if-changed messages in `JsRuntime` -- those are printed elsewhere * We no longer special case the OwnedIsolate for snapshots. Instead we make use of an inner object that has the `Drop` impl and allows us to `std::mem::forget` it if we need to extract the isolate for a snapshot * The `snapshot` method is only available on `JsRuntimeForSnapshot`, not `JsRuntime`. * `OpState` construction is slightly cleaner, though I'd still like to extract more --------- Co-authored-by: Bartek IwaƄczuk --- core/examples/http_bench_json_ops/main.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'core/examples/http_bench_json_ops') diff --git a/core/examples/http_bench_json_ops/main.rs b/core/examples/http_bench_json_ops/main.rs index 7c15f7bf2..36c0996c3 100644 --- a/core/examples/http_bench_json_ops/main.rs +++ b/core/examples/http_bench_json_ops/main.rs @@ -3,7 +3,7 @@ use deno_core::anyhow::Error; use deno_core::op; use deno_core::AsyncRefCell; use deno_core::AsyncResult; -use deno_core::JsRuntime; +use deno_core::JsRuntimeForSnapshot; use deno_core::OpState; use deno_core::Resource; use deno_core::ResourceId; @@ -93,7 +93,7 @@ impl From for TcpStream { } } -fn create_js_runtime() -> JsRuntime { +fn create_js_runtime() -> JsRuntimeForSnapshot { let ext = deno_core::Extension::builder("my_ext") .ops(vec![ op_listen::decl(), @@ -103,11 +103,13 @@ fn create_js_runtime() -> JsRuntime { ]) .build(); - JsRuntime::new(deno_core::RuntimeOptions { - extensions: vec![ext], - will_snapshot: false, - ..Default::default() - }) + JsRuntimeForSnapshot::new( + deno_core::RuntimeOptions { + extensions: vec![ext], + ..Default::default() + }, + Default::default(), + ) } #[op] -- cgit v1.2.3