mirror of
https://github.com/denoland/deno
synced 2024-08-27 12:00:17 +00:00
Move Modules to ThreadSafeState (#2498)
This commit is contained in:
parent
508e9849ff
commit
de8c85f8f2
|
@ -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);
|
println!("{}{}", ansi::bold("deps:\n".to_string()), deps.name);
|
||||||
if let Some(ref depsdeps) = deps.deps {
|
if let Some(ref depsdeps) = deps.deps {
|
||||||
|
|
|
@ -60,6 +60,7 @@ pub struct ThreadSafeState(Arc<State>);
|
||||||
|
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(stutter))]
|
#[cfg_attr(feature = "cargo-clippy", allow(stutter))]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
|
pub modules: Arc<Mutex<deno::Modules>>,
|
||||||
pub main_module: Option<String>,
|
pub main_module: Option<String>,
|
||||||
pub dir: deno_dir::DenoDir,
|
pub dir: deno_dir::DenoDir,
|
||||||
pub argv: Vec<String>,
|
pub argv: Vec<String>,
|
||||||
|
@ -303,8 +304,11 @@ impl ThreadSafeState {
|
||||||
seeded_rng = Some(Mutex::new(StdRng::seed_from_u64(seed)));
|
seeded_rng = Some(Mutex::new(StdRng::seed_from_u64(seed)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let modules = Arc::new(Mutex::new(deno::Modules::new()));
|
||||||
|
|
||||||
ThreadSafeState(Arc::new(State {
|
ThreadSafeState(Arc::new(State {
|
||||||
main_module,
|
main_module,
|
||||||
|
modules,
|
||||||
dir,
|
dir,
|
||||||
argv: argv_rest,
|
argv: argv_rest,
|
||||||
permissions: DenoPermissions::from_flags(&flags),
|
permissions: DenoPermissions::from_flags(&flags),
|
||||||
|
|
|
@ -19,7 +19,6 @@ use url::Url;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Worker {
|
pub struct Worker {
|
||||||
inner: Arc<Mutex<deno::Isolate>>,
|
inner: Arc<Mutex<deno::Isolate>>,
|
||||||
pub modules: Arc<Mutex<deno::Modules>>,
|
|
||||||
pub state: ThreadSafeState,
|
pub state: ThreadSafeState,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +35,6 @@ impl Worker {
|
||||||
});
|
});
|
||||||
Self {
|
Self {
|
||||||
inner: Arc::new(Mutex::new(deno::Isolate::new(startup_data, config))),
|
inner: Arc::new(Mutex::new(deno::Isolate::new(startup_data, config))),
|
||||||
modules: Arc::new(Mutex::new(deno::Modules::new())),
|
|
||||||
state,
|
state,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +65,7 @@ impl Worker {
|
||||||
let worker_ = worker.clone();
|
let worker_ = worker.clone();
|
||||||
let loader = self.state.clone();
|
let loader = self.state.clone();
|
||||||
let isolate = self.inner.clone();
|
let isolate = self.inner.clone();
|
||||||
let modules = self.modules.clone();
|
let modules = self.state.modules.clone();
|
||||||
let recursive_load =
|
let recursive_load =
|
||||||
deno::RecursiveLoad::new(js_url.as_str(), loader, isolate, modules);
|
deno::RecursiveLoad::new(js_url.as_str(), loader, isolate, modules);
|
||||||
recursive_load
|
recursive_load
|
||||||
|
|
Loading…
Reference in a new issue