summaryrefslogtreecommitdiff
path: root/core/ops_builtin_v8.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/ops_builtin_v8.rs')
-rw-r--r--core/ops_builtin_v8.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/ops_builtin_v8.rs b/core/ops_builtin_v8.rs
index 7f0c58212..4bc80faa5 100644
--- a/core/ops_builtin_v8.rs
+++ b/core/ops_builtin_v8.rs
@@ -47,6 +47,7 @@ pub(crate) fn init_builtins_v8() -> Vec<OpDecl> {
op_op_names::decl(),
op_apply_source_map::decl(),
op_set_format_exception_callback::decl(),
+ op_event_loop_has_more_work::decl(),
]
}
@@ -786,3 +787,26 @@ fn op_set_format_exception_callback<'a>(
let old = old.map(|v| v8::Local::new(scope, v));
Ok(old.map(|v| from_v8(scope, v.into()).unwrap()))
}
+
+#[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
+}