diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-30 16:38:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-30 10:38:35 -0400 |
commit | 5ec478b5fa6261e2b2d3c8daed3cba9e780730c7 (patch) | |
tree | 9662acbbfca40b2a5aea25b63f239e39bd254c37 /core/runtime.rs | |
parent | f31ee8d1bfc50de6cef5b746f6fd6431b7b772e5 (diff) |
refactor(core): initialize extensions in runtime constructor (#10421)
This ensures that provided extensions are all correctly setup and ready to use once the JsRuntime constructor returns
Note: this will also initialize ops for to-be-snapshotted runtimes
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 4cfcad0ba..7573dfb67 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -313,9 +313,16 @@ impl JsRuntime { extensions: options.extensions, }; + // TODO(@AaronO): diff extensions inited in snapshot and those provided + // for now we assume that snapshot and extensions always match if !has_startup_snapshot { js_runtime.js_init(); + js_runtime.init_extension_js().unwrap(); } + // Init extension ops + js_runtime.init_extension_ops().unwrap(); + js_runtime.sync_ops_cache(); + // Init async ops callback js_runtime.init_recv_cb(); js_runtime @@ -366,8 +373,7 @@ impl JsRuntime { } /// Initializes JS of provided Extensions - // NOTE: this will probably change when streamlining snapshot flow - pub fn init_extension_js(&mut self) -> Result<(), AnyError> { + fn init_extension_js(&mut self) -> Result<(), AnyError> { // Take extensions to avoid double-borrow let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions); for m in extensions.iter_mut() { @@ -384,8 +390,7 @@ impl JsRuntime { } /// Initializes ops of provided Extensions - // NOTE: this will probably change when streamlining snapshot flow - pub fn init_extension_ops(&mut self) -> Result<(), AnyError> { + fn init_extension_ops(&mut self) -> Result<(), AnyError> { let op_state = self.op_state(); // Take extensions to avoid double-borrow let mut extensions: Vec<Extension> = std::mem::take(&mut self.extensions); |