summaryrefslogtreecommitdiff
path: root/core/modules.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2021-03-04 12:19:47 +0000
committerGitHub <noreply@github.com>2021-03-04 13:19:47 +0100
commit0f2121355f65baa27b530ef286c8b4ca0009fabf (patch)
tree646725573df762eb09035dd7533e9d4d40280461 /core/modules.rs
parentaf7e02124fbec3cd3b2d17f6fa88682b826e455e (diff)
fix(runtime/web_worker): Don't block self.onmessage with TLA (#9619)
This commit rewrites implementation of "JsRuntime::mod_evaluate". Event loop is no longer polled automatically and users must manually drive event loop forward after calling "mod_evaluate". Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com> Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'core/modules.rs')
-rw-r--r--core/modules.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/modules.rs b/core/modules.rs
index ea772a8b2..b9b99d3b5 100644
--- a/core/modules.rs
+++ b/core/modules.rs
@@ -687,7 +687,8 @@ mod tests {
let a_id_fut = runtime.load_module(&spec, None);
let a_id = futures::executor::block_on(a_id_fut).expect("Failed to load");
- futures::executor::block_on(runtime.mod_evaluate(a_id)).unwrap();
+ runtime.mod_evaluate(a_id);
+ futures::executor::block_on(runtime.run_event_loop()).unwrap();
let l = loads.lock().unwrap();
assert_eq!(
l.to_vec(),
@@ -754,7 +755,8 @@ mod tests {
let result = runtime.load_module(&spec, None).await;
assert!(result.is_ok());
let circular1_id = result.unwrap();
- runtime.mod_evaluate(circular1_id).await.unwrap();
+ runtime.mod_evaluate(circular1_id);
+ runtime.run_event_loop().await.unwrap();
let l = loads.lock().unwrap();
assert_eq!(
@@ -827,7 +829,8 @@ mod tests {
println!(">> result {:?}", result);
assert!(result.is_ok());
let redirect1_id = result.unwrap();
- runtime.mod_evaluate(redirect1_id).await.unwrap();
+ runtime.mod_evaluate(redirect1_id);
+ runtime.run_event_loop().await.unwrap();
let l = loads.lock().unwrap();
assert_eq!(
l.to_vec(),
@@ -976,7 +979,8 @@ mod tests {
let main_id =
futures::executor::block_on(main_id_fut).expect("Failed to load");
- futures::executor::block_on(runtime.mod_evaluate(main_id)).unwrap();
+ runtime.mod_evaluate(main_id);
+ futures::executor::block_on(runtime.run_event_loop()).unwrap();
let l = loads.lock().unwrap();
assert_eq!(