summaryrefslogtreecommitdiff
path: root/cli/compilers/ts.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-01-21 17:50:06 +0100
committerGitHub <noreply@github.com>2020-01-21 17:50:06 +0100
commitecd1d3abb0cae9c7cbc1330cbaa035a5786e94d7 (patch)
tree73d4b12a06f5f6a6bc0e7168e0021efc3a2eda7c /cli/compilers/ts.rs
parent229eb292f83dedbc32dc24f912841caf79a53e9c (diff)
refactor: split cli::Worker (#3735)
* cli::Worker is base struct to create specialized workers * add MainWorker * add CompilerWorker * refactor WebWorker to use Worker
Diffstat (limited to 'cli/compilers/ts.rs')
-rw-r--r--cli/compilers/ts.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/cli/compilers/ts.rs b/cli/compilers/ts.rs
index f3147334f..3adf92495 100644
--- a/cli/compilers/ts.rs
+++ b/cli/compilers/ts.rs
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+use super::compiler_worker::CompilerWorker;
use crate::compilers::CompilationResultFuture;
use crate::compilers::CompiledModule;
use crate::compilers::CompiledModuleFuture;
@@ -13,7 +14,6 @@ use crate::source_maps::SourceMapGetter;
use crate::startup_data;
use crate::state::*;
use crate::version;
-use crate::worker::Worker;
use deno_core::Buf;
use deno_core::ErrBox;
use deno_core::ModuleSpecifier;
@@ -228,7 +228,7 @@ impl TsCompiler {
}
/// Create a new V8 worker with snapshot of TS compiler and setup compiler's runtime.
- fn setup_worker(global_state: ThreadSafeGlobalState) -> Worker {
+ fn setup_worker(global_state: ThreadSafeGlobalState) -> CompilerWorker {
let (int, ext) = ThreadSafeState::create_channels();
let worker_state =
ThreadSafeState::new(global_state.clone(), None, None, int)
@@ -240,7 +240,7 @@ impl TsCompiler {
.compiler_starts
.fetch_add(1, Ordering::SeqCst);
- let mut worker = Worker::new(
+ let mut worker = CompilerWorker::new(
"TS".to_string(),
startup_data::compiler_isolate_init(),
worker_state,
@@ -279,7 +279,7 @@ impl TsCompiler {
worker.post_message(req_msg).await?;
worker.await?;
debug!("Sent message to worker");
- let maybe_msg = worker_.get_message().await?;
+ let maybe_msg = worker_.get_message().await;
debug!("Received message from worker");
if let Some(msg) = maybe_msg {
let json_str = std::str::from_utf8(&msg).unwrap();
@@ -378,7 +378,7 @@ impl TsCompiler {
worker.post_message(req_msg).await?;
worker.await?;
debug!("Sent message to worker");
- let maybe_msg = worker_.get_message().await?;
+ let maybe_msg = worker_.get_message().await;
if let Some(msg) = maybe_msg {
let json_str = std::str::from_utf8(&msg).unwrap();
debug!("Message: {}", json_str);
@@ -633,7 +633,7 @@ pub fn runtime_compile_async<S: BuildHasher>(
worker.post_message(req_msg).await?;
worker.await?;
debug!("Sent message to worker");
- let msg = (worker_.get_message().await?).unwrap();
+ let msg = (worker_.get_message().await).unwrap();
let json_str = std::str::from_utf8(&msg).unwrap();
Ok(json!(json_str))
}
@@ -661,7 +661,7 @@ pub fn runtime_transpile_async<S: BuildHasher>(
worker.post_message(req_msg).await?;
worker.await?;
debug!("Sent message to worker");
- let msg = (worker_.get_message().await?).unwrap();
+ let msg = (worker_.get_message().await).unwrap();
let json_str = std::str::from_utf8(&msg).unwrap();
Ok(json!(json_str))
}