summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-12-11 18:49:26 +0100
committerGitHub <noreply@github.com>2020-12-11 18:49:26 +0100
commit65e72b68acf57da8462b8e7b057e7adb9393b698 (patch)
tree00e955e1186b9512b009acbb6ee80feb8a3f1733 /core/runtime.rs
parent9414dee9e56a9f42c07ada4f8e1be864a1a1b936 (diff)
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.
Diffstat (limited to 'core/runtime.rs')
-rw-r--r--core/runtime.rs6
1 files changed, 3 insertions, 3 deletions
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<v8::Promise>, v8::Global<v8::Value>>,
pending_dyn_mod_evaluate: HashMap<ModuleLoadId, DynImportModEvaluate>,
pending_mod_evaluate: Option<ModEvaluate>,
- pub(crate) js_error_create_fn: Box<JsErrorCreateFn>,
+ pub(crate) js_error_create_fn: Rc<JsErrorCreateFn>,
pub(crate) shared: SharedQueue,
pub(crate) pending_ops: FuturesUnordered<PendingOpFuture>,
pub(crate) pending_unref_ops: FuturesUnordered<PendingOpFuture>,
@@ -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<Box<JsErrorCreateFn>>,
+ pub js_error_create_fn: Option<Rc<JsErrorCreateFn>>,
/// 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 {