refactor: split cli::Worker (#3735)

* cli::Worker is base struct to create specialized workers
* add MainWorker
* add CompilerWorker
* refactor WebWorker to use Worker
This commit is contained in:
Bartek Iwańczuk 2020-01-21 17:50:06 +01:00 committed by GitHub
parent 229eb292f8
commit ecd1d3abb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 299 additions and 280 deletions

View file

@ -60,7 +60,7 @@ use crate::global_state::ThreadSafeGlobalState;
use crate::ops::io::get_stdio;
use crate::progress::Progress;
use crate::state::ThreadSafeState;
use crate::worker::Worker;
use crate::worker::MainWorker;
use deno_core::v8_set_flags;
use deno_core::ErrBox;
use deno_core::ModuleSpecifier;
@ -97,7 +97,7 @@ impl log::Log for Logger {
fn create_worker_and_state(
flags: DenoFlags,
) -> (Worker, ThreadSafeGlobalState) {
) -> (MainWorker, ThreadSafeGlobalState) {
use crate::shell::Shell;
use std::sync::Arc;
use std::sync::Mutex;
@ -135,7 +135,7 @@ fn create_worker_and_state(
resource_table.add("stderr", Box::new(stderr));
}
let worker = Worker::new(
let worker = MainWorker::new(
"main".to_string(),
startup_data::deno_isolate_init(),
state,
@ -150,7 +150,7 @@ fn types_command() {
println!("{}", content);
}
fn print_cache_info(worker: Worker) {
fn print_cache_info(worker: MainWorker) {
let state = &worker.state.global_state;
println!(
@ -170,7 +170,10 @@ fn print_cache_info(worker: Worker) {
);
}
async fn print_file_info(worker: Worker, module_specifier: ModuleSpecifier) {
async fn print_file_info(
worker: MainWorker,
module_specifier: ModuleSpecifier,
) {
let global_state_ = &worker.state.global_state;
let maybe_source_file = global_state_