summaryrefslogtreecommitdiff
path: root/core/modules.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-05-26 21:07:12 +0200
committerGitHub <noreply@github.com>2021-05-26 21:07:12 +0200
commite5beb800c94099852964d482a32a13f5c29ec147 (patch)
tree1ad89cc15efa84efe690e05b18d5827e1983dbca /core/modules.rs
parente9edd7e14d9d78f03c5f2e67fcc44e4dbaab8f2c (diff)
refactor: move JsRuntimeInspector to deno_core (#10763)
This commit moves implementation of "JsRuntimeInspector" to "deno_core" crate. To achieve that following changes were made: * "Worker" and "WebWorker" no longer own instance of "JsRuntimeInspector", instead it is now owned by "deno_core::JsRuntime". * Consequently polling of inspector is no longer done in "Worker"/"WebWorker", instead it's done in "deno_core::JsRuntime::poll_event_loop". * "deno_core::JsRuntime::poll_event_loop" and "deno_core::JsRuntime::run_event_loop", now accept "wait_for_inspector" boolean that tells if event loop should still be "pending" if there are active inspector sessions - this change fixes the problem that inspector disconnects from the frontend and process exits once the code has stopped executing.
Diffstat (limited to 'core/modules.rs')
-rw-r--r--core/modules.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/core/modules.rs b/core/modules.rs
index a21286941..642dcc26a 100644
--- a/core/modules.rs
+++ b/core/modules.rs
@@ -902,7 +902,7 @@ mod tests {
let a_id = futures::executor::block_on(a_id_fut).expect("Failed to load");
runtime.mod_evaluate(a_id);
- futures::executor::block_on(runtime.run_event_loop()).unwrap();
+ futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
let l = loads.lock().unwrap();
assert_eq!(
l.to_vec(),
@@ -1130,7 +1130,7 @@ mod tests {
assert_eq!(count.load(Ordering::Relaxed), 0);
// We should get an error here.
- let result = runtime.poll_event_loop(cx);
+ let result = runtime.poll_event_loop(cx, false);
if let Poll::Ready(Ok(_)) = result {
unreachable!();
}
@@ -1223,14 +1223,20 @@ mod tests {
.unwrap();
// First poll runs `prepare_load` hook.
- assert!(matches!(runtime.poll_event_loop(cx), Poll::Pending));
+ assert!(matches!(runtime.poll_event_loop(cx, false), Poll::Pending));
assert_eq!(prepare_load_count.load(Ordering::Relaxed), 1);
// Second poll actually loads modules into the isolate.
- assert!(matches!(runtime.poll_event_loop(cx), Poll::Ready(Ok(_))));
+ assert!(matches!(
+ runtime.poll_event_loop(cx, false),
+ Poll::Ready(Ok(_))
+ ));
assert_eq!(resolve_count.load(Ordering::Relaxed), 4);
assert_eq!(load_count.load(Ordering::Relaxed), 2);
- assert!(matches!(runtime.poll_event_loop(cx), Poll::Ready(Ok(_))));
+ assert!(matches!(
+ runtime.poll_event_loop(cx, false),
+ Poll::Ready(Ok(_))
+ ));
assert_eq!(resolve_count.load(Ordering::Relaxed), 4);
assert_eq!(load_count.load(Ordering::Relaxed), 2);
})
@@ -1261,10 +1267,10 @@ mod tests {
)
.unwrap();
// First poll runs `prepare_load` hook.
- let _ = runtime.poll_event_loop(cx);
+ let _ = runtime.poll_event_loop(cx, false);
assert_eq!(prepare_load_count.load(Ordering::Relaxed), 1);
// Second poll triggers error
- let _ = runtime.poll_event_loop(cx);
+ let _ = runtime.poll_event_loop(cx, false);
})
}
@@ -1283,7 +1289,7 @@ mod tests {
assert!(result.is_ok());
let circular1_id = result.unwrap();
runtime.mod_evaluate(circular1_id);
- runtime.run_event_loop().await.unwrap();
+ runtime.run_event_loop(false).await.unwrap();
let l = loads.lock().unwrap();
assert_eq!(
@@ -1356,7 +1362,7 @@ mod tests {
assert!(result.is_ok());
let redirect1_id = result.unwrap();
runtime.mod_evaluate(redirect1_id);
- runtime.run_event_loop().await.unwrap();
+ runtime.run_event_loop(false).await.unwrap();
let l = loads.lock().unwrap();
assert_eq!(
l.to_vec(),
@@ -1505,7 +1511,7 @@ mod tests {
futures::executor::block_on(main_id_fut).expect("Failed to load");
runtime.mod_evaluate(main_id);
- futures::executor::block_on(runtime.run_event_loop()).unwrap();
+ futures::executor::block_on(runtime.run_event_loop(false)).unwrap();
let l = loads.lock().unwrap();
assert_eq!(