diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-05-31 08:19:06 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-31 08:19:06 -0600 |
commit | 8e84dc0139055db8c84ad28723114d343982a8f7 (patch) | |
tree | 93238866035949af70c32769e651f0f3fae5cf83 /core/examples/http_bench_json_ops/main.rs | |
parent | d0efd040c79021958a1e83caa56572c0401ca1f2 (diff) |
chore(core): Split JsRuntimeForSnapshot from JsRuntime (#19308)
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 <biwanczuk@gmail.com>
Diffstat (limited to 'core/examples/http_bench_json_ops/main.rs')
-rw-r--r-- | core/examples/http_bench_json_ops/main.rs | 16 |
1 files changed, 9 insertions, 7 deletions
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<tokio::net::TcpStream> 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] |