summaryrefslogtreecommitdiff
path: root/cli/compilers
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-05 11:13:10 +0100
committerGitHub <noreply@github.com>2020-03-05 11:13:10 +0100
commit52b96fc22a93c804702617f20d24ed115fd5a780 (patch)
treec6e82803b29a2d08662a73b3e85c7bd0821724c1 /cli/compilers
parent159de0245d1924cdc0f007d96bfbfdab85f08ded (diff)
refactor: cleanup compiler runtimes (#4230)
- Cleanup "tsCompilerOnMessage" by factoring out separate methods for each request type: * "compile" * "runtimeCompile" * "runtimeTranspile" - Simplify control flow of compiler workers by a) no longer calling "close()" in worker runtime after a single message; b) explicitly shutting down worker from host after a single message Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/compilers')
-rw-r--r--cli/compilers/ts.rs6
-rw-r--r--cli/compilers/wasm.rs6
2 files changed, 2 insertions, 10 deletions
diff --git a/cli/compilers/ts.rs b/cli/compilers/ts.rs
index b08a12beb..f2c8e41fe 100644
--- a/cli/compilers/ts.rs
+++ b/cli/compilers/ts.rs
@@ -620,11 +620,7 @@ async fn execute_in_thread(
WorkerEvent::Message(buf) => Ok(buf),
WorkerEvent::Error(error) => Err(error),
}?;
- // Compiler worker finishes after one request
- // so we should receive signal that channel was closed.
- // Then close worker's channel and join the thread.
- let event = handle.get_event().await;
- assert!(event.is_none());
+ // Shutdown worker and wait for thread to finish
handle.sender.close_channel();
join_handle.join().unwrap();
Ok(buf)
diff --git a/cli/compilers/wasm.rs b/cli/compilers/wasm.rs
index bcdc8a51c..bd22a2523 100644
--- a/cli/compilers/wasm.rs
+++ b/cli/compilers/wasm.rs
@@ -134,11 +134,7 @@ async fn execute_in_thread(
WorkerEvent::Message(buf) => Ok(buf),
WorkerEvent::Error(error) => Err(error),
}?;
- // Compiler worker finishes after one request
- // so we should receive signal that channel was closed.
- // Then close worker's channel and join the thread.
- let event = handle.get_event().await;
- assert!(event.is_none());
+ // Shutdown worker and wait for thread to finish
handle.sender.close_channel();
join_handle.join().unwrap();
Ok(buf)