summaryrefslogtreecommitdiff
path: root/core/ops_builtin_v8.rs
diff options
context:
space:
mode:
authorAndreu Botella <andreu@andreubotella.com>2022-07-11 12:08:37 +0200
committerGitHub <noreply@github.com>2022-07-11 12:08:37 +0200
commit83c9714fb2f401e82a6c2e784a43130818e8282d (patch)
tree558bc6b9677e27ed482bffe0cfc5ca35aff7c20e /core/ops_builtin_v8.rs
parentd70ba324feadcb0c6238dd3f0e04a53bb8448147 (diff)
chore(core): Deduplicate code related to `op_event_loop_has_more_work` (#15147)
The `op_event_loop_has_more_work` op, introduced in #14830, duplicates code from `JsRuntime::poll_event_loop`. That PR also added the unused method `JsRuntime::event_loop_has_work`, which is another duplication of that same code, and which isn't used anywhere. This change deduplicates this by renaming `JsRuntime::event_loop_has_work` to `event_loop_pending_state`, and making it the single place to determine what in the event loop is pending. This result is then returned in a struct which is used both in the event loop and in the `op_event_loop_has_more_work` op.
Diffstat (limited to 'core/ops_builtin_v8.rs')
-rw-r--r--core/ops_builtin_v8.rs20
1 files changed, 1 insertions, 19 deletions
diff --git a/core/ops_builtin_v8.rs b/core/ops_builtin_v8.rs
index 4bc80faa5..39469c0ad 100644
--- a/core/ops_builtin_v8.rs
+++ b/core/ops_builtin_v8.rs
@@ -790,23 +790,5 @@ fn op_set_format_exception_callback<'a>(
#[op(v8)]
fn op_event_loop_has_more_work(scope: &mut v8::HandleScope) -> bool {
- let state_rc = JsRuntime::state(scope);
- let module_map_rc = JsRuntime::module_map(scope);
- let state = state_rc.borrow_mut();
- let module_map = module_map_rc.borrow();
-
- let has_pending_refed_ops = state.pending_ops.len() > state.unrefed_ops.len();
- let has_pending_dyn_imports = module_map.has_pending_dynamic_imports();
- let has_pending_dyn_module_evaluation =
- !state.pending_dyn_mod_evaluate.is_empty();
- let has_pending_module_evaluation = state.pending_mod_evaluate.is_some();
- let has_pending_background_tasks = scope.has_pending_background_tasks();
- let has_tick_scheduled = state.has_tick_scheduled;
-
- has_pending_refed_ops
- || has_pending_dyn_imports
- || has_pending_dyn_module_evaluation
- || has_pending_module_evaluation
- || has_pending_background_tasks
- || has_tick_scheduled
+ JsRuntime::event_loop_pending_state(scope).is_pending()
}