diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-06-11 14:35:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-11 14:35:03 -0400 |
commit | de8c85f8f2f4631cc4e7cba2616df94fd2c37160 (patch) | |
tree | 9055aa499839093145083cc54ca6ffe312e5c13d | |
parent | 508e9849ffd1491b8f3ac9aaaad507e84f57fed3 (diff) |
Move Modules to ThreadSafeState (#2498)
-rw-r--r-- | cli/main.rs | 3 | ||||
-rw-r--r-- | cli/state.rs | 4 | ||||
-rw-r--r-- | cli/worker.rs | 4 |
3 files changed, 7 insertions, 4 deletions
diff --git a/cli/main.rs b/cli/main.rs index 132bd7bc0..5976d42ba 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -126,7 +126,8 @@ pub fn print_file_info( ); } - if let Some(deps) = worker.modules.lock().unwrap().deps(&out.module_name) + if let Some(deps) = + worker.state.modules.lock().unwrap().deps(&out.module_name) { println!("{}{}", ansi::bold("deps:\n".to_string()), deps.name); if let Some(ref depsdeps) = deps.deps { diff --git a/cli/state.rs b/cli/state.rs index 255a88144..07fb8189b 100644 --- a/cli/state.rs +++ b/cli/state.rs @@ -60,6 +60,7 @@ pub struct ThreadSafeState(Arc<State>); #[cfg_attr(feature = "cargo-clippy", allow(stutter))] pub struct State { + pub modules: Arc<Mutex<deno::Modules>>, pub main_module: Option<String>, pub dir: deno_dir::DenoDir, pub argv: Vec<String>, @@ -303,8 +304,11 @@ impl ThreadSafeState { seeded_rng = Some(Mutex::new(StdRng::seed_from_u64(seed))); }; + let modules = Arc::new(Mutex::new(deno::Modules::new())); + ThreadSafeState(Arc::new(State { main_module, + modules, dir, argv: argv_rest, permissions: DenoPermissions::from_flags(&flags), diff --git a/cli/worker.rs b/cli/worker.rs index 99470c2a7..aff461a94 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -19,7 +19,6 @@ use url::Url; #[derive(Clone)] pub struct Worker { inner: Arc<Mutex<deno::Isolate>>, - pub modules: Arc<Mutex<deno::Modules>>, pub state: ThreadSafeState, } @@ -36,7 +35,6 @@ impl Worker { }); Self { inner: Arc::new(Mutex::new(deno::Isolate::new(startup_data, config))), - modules: Arc::new(Mutex::new(deno::Modules::new())), state, } } @@ -67,7 +65,7 @@ impl Worker { let worker_ = worker.clone(); let loader = self.state.clone(); let isolate = self.inner.clone(); - let modules = self.modules.clone(); + let modules = self.state.modules.clone(); let recursive_load = deno::RecursiveLoad::new(js_url.as_str(), loader, isolate, modules); recursive_load |