From 27f4aeb92469660fdd78a89a7b2902c08a23ca4a Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 18 Aug 2020 18:30:13 +0200 Subject: Make Rc/Arc wrapper around State/GlobalState visible (#7104) --- cli/ops/runtime.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'cli/ops/runtime.rs') diff --git a/cli/ops/runtime.rs b/cli/ops/runtime.rs index 55f0d9f57..b4fb3c496 100644 --- a/cli/ops/runtime.rs +++ b/cli/ops/runtime.rs @@ -9,19 +9,19 @@ use deno_core::CoreIsolate; use deno_core::ModuleSpecifier; use deno_core::ZeroCopyBuf; use std::env; +use std::rc::Rc; -pub fn init(i: &mut CoreIsolate, s: &State) { +pub fn init(i: &mut CoreIsolate, s: &Rc) { i.register_op("op_start", s.stateful_json_op(op_start)); i.register_op("op_main_module", s.stateful_json_op(op_main_module)); i.register_op("op_metrics", s.stateful_json_op(op_metrics)); } fn op_start( - state: &State, + state: &Rc, _args: Value, _zero_copy: &mut [ZeroCopyBuf], ) -> Result { - let state = state.borrow(); let gs = &state.global_state; Ok(JsonOp::Sync(json!({ @@ -43,11 +43,11 @@ fn op_start( } fn op_main_module( - state: &State, + state: &Rc, _args: Value, _zero_copy: &mut [ZeroCopyBuf], ) -> Result { - let main = &state.borrow().main_module.to_string(); + let main = &state.main_module.to_string(); let main_url = ModuleSpecifier::resolve_url_or_path(&main)?; if main_url.as_url().scheme() == "file" { let main_path = std::env::current_dir().unwrap().join(main_url.to_string()); @@ -57,12 +57,11 @@ fn op_main_module( } fn op_metrics( - state: &State, + state: &Rc, _args: Value, _zero_copy: &mut [ZeroCopyBuf], ) -> Result { - let state = state.borrow(); - let m = &state.metrics; + let m = &state.metrics.borrow(); Ok(JsonOp::Sync(json!({ "opsDispatched": m.ops_dispatched, -- cgit v1.2.3