未验证 提交 d1b88510 编写于 作者: B Bartek Iwańczuk 提交者: GitHub

refactor: remove GlobalState::compile_lock (#7598)

上级 0a9d7e4e
...@@ -19,7 +19,6 @@ use std::env; ...@@ -19,7 +19,6 @@ use std::env;
use std::sync::atomic::AtomicUsize; use std::sync::atomic::AtomicUsize;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Mutex; use std::sync::Mutex;
use tokio::sync::Mutex as AsyncMutex;
pub fn exit_unstable(api_name: &str) { pub fn exit_unstable(api_name: &str) {
eprintln!( eprintln!(
...@@ -43,7 +42,6 @@ pub struct GlobalState { ...@@ -43,7 +42,6 @@ pub struct GlobalState {
pub lockfile: Option<Mutex<Lockfile>>, pub lockfile: Option<Mutex<Lockfile>>,
pub compiler_starts: AtomicUsize, pub compiler_starts: AtomicUsize,
pub maybe_import_map: Option<ImportMap>, pub maybe_import_map: Option<ImportMap>,
compile_lock: AsyncMutex<()>,
} }
impl GlobalState { impl GlobalState {
...@@ -96,7 +94,6 @@ impl GlobalState { ...@@ -96,7 +94,6 @@ impl GlobalState {
lockfile, lockfile,
maybe_import_map, maybe_import_map,
compiler_starts: AtomicUsize::new(0), compiler_starts: AtomicUsize::new(0),
compile_lock: AsyncMutex::new(()),
}; };
Ok(Arc::new(global_state)) Ok(Arc::new(global_state))
} }
...@@ -116,10 +113,6 @@ impl GlobalState { ...@@ -116,10 +113,6 @@ impl GlobalState {
) -> Result<(), AnyError> { ) -> Result<(), AnyError> {
let module_specifier = module_specifier.clone(); let module_specifier = module_specifier.clone();
// TODO(ry) Try to lift compile_lock as high up in the call stack for
// sanity.
let compile_lock = self.compile_lock.lock().await;
let mut module_graph_loader = ModuleGraphLoader::new( let mut module_graph_loader = ModuleGraphLoader::new(
self.file_fetcher.clone(), self.file_fetcher.clone(),
maybe_import_map, maybe_import_map,
...@@ -180,8 +173,6 @@ impl GlobalState { ...@@ -180,8 +173,6 @@ impl GlobalState {
g.write()?; g.write()?;
} }
drop(compile_lock);
Ok(()) Ok(())
} }
...@@ -195,17 +186,11 @@ impl GlobalState { ...@@ -195,17 +186,11 @@ impl GlobalState {
module_specifier: ModuleSpecifier, module_specifier: ModuleSpecifier,
_maybe_referrer: Option<ModuleSpecifier>, _maybe_referrer: Option<ModuleSpecifier>,
) -> Result<CompiledModule, AnyError> { ) -> Result<CompiledModule, AnyError> {
let module_specifier = module_specifier.clone();
let out = self let out = self
.file_fetcher .file_fetcher
.fetch_cached_source_file(&module_specifier, Permissions::allow_all()) .fetch_cached_source_file(&module_specifier, Permissions::allow_all())
.expect("Cached source file doesn't exist"); .expect("Cached source file doesn't exist");
// TODO(ry) Try to lift compile_lock as high up in the call stack for
// sanity.
let compile_lock = self.compile_lock.lock().await;
// Check if we need to compile files // Check if we need to compile files
let was_compiled = match out.media_type { let was_compiled = match out.media_type {
MediaType::TypeScript | MediaType::TSX | MediaType::JSX => true, MediaType::TypeScript | MediaType::TSX | MediaType::JSX => true,
...@@ -237,8 +222,6 @@ impl GlobalState { ...@@ -237,8 +222,6 @@ impl GlobalState {
} }
}; };
drop(compile_lock);
Ok(compiled_module) Ok(compiled_module)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册