From 65e72b68acf57da8462b8e7b057e7adb9393b698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 11 Dec 2020 18:49:26 +0100 Subject: refactor(cli): decouple ops from ProgramState and Flags (#8659) This commit does major refactor of "Worker" and "WebWorker", in order to decouple them from "ProgramState" and "Flags". The main points of interest are "create_main_worker()" and "create_web_worker_callback()" functions which are responsible for creating "Worker" and "WebWorker" in CLI context. As a result it is now possible to factor out common "runtime" functionality into a separate crate. --- core/runtime.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/runtime.rs') diff --git a/core/runtime.rs b/core/runtime.rs index 0f09926f8..24bdf4dc2 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -107,7 +107,7 @@ pub(crate) struct JsRuntimeState { HashMap, v8::Global>, pending_dyn_mod_evaluate: HashMap, pending_mod_evaluate: Option, - pub(crate) js_error_create_fn: Box, + pub(crate) js_error_create_fn: Rc, pub(crate) shared: SharedQueue, pub(crate) pending_ops: FuturesUnordered, pub(crate) pending_unref_ops: FuturesUnordered, @@ -168,7 +168,7 @@ pub struct RuntimeOptions { /// Allows a callback to be set whenever a V8 exception is made. This allows /// the caller to wrap the JsError into an error. By default this callback /// is set to `JsError::create()`. - pub js_error_create_fn: Option>, + pub js_error_create_fn: Option>, /// Allows to map error type to a string "class" used to represent /// error in JavaScript. @@ -257,7 +257,7 @@ impl JsRuntime { let js_error_create_fn = options .js_error_create_fn - .unwrap_or_else(|| Box::new(JsError::create)); + .unwrap_or_else(|| Rc::new(JsError::create)); let mut op_state = OpState::default(); if let Some(get_error_class_fn) = options.get_error_class_fn { -- cgit v1.2.3