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/ops.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/ops.rs')
-rw-r--r-- | core/ops.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/ops.rs b/core/ops.rs index 2614c3a87..5f1bf67ef 100644 --- a/core/ops.rs +++ b/core/ops.rs @@ -183,7 +183,7 @@ pub struct OpState { pub get_error_class_fn: GetErrorClassFn, pub tracker: OpsTracker, pub last_fast_op_error: Option<AnyError>, - gotham_state: GothamState, + pub(crate) gotham_state: GothamState, } impl OpState { @@ -196,6 +196,12 @@ impl OpState { tracker: OpsTracker::new(ops_count), } } + + /// Clear all user-provided resources and state. + pub(crate) fn clear(&mut self) { + std::mem::take(&mut self.gotham_state); + std::mem::take(&mut self.resource_table); + } } impl Deref for OpState { |