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

refactor: remove GlobalState::compile_lock (#7598)

上级 0a9d7e4e
......@@ -19,7 +19,6 @@ use std::env;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
use std::sync::Mutex;
use tokio::sync::Mutex as AsyncMutex;
pub fn exit_unstable(api_name: &str) {
eprintln!(
......@@ -43,7 +42,6 @@ pub struct GlobalState {
pub lockfile: Option<Mutex<Lockfile>>,
pub compiler_starts: AtomicUsize,
pub maybe_import_map: Option<ImportMap>,
compile_lock: AsyncMutex<()>,
}
impl GlobalState {
......@@ -96,7 +94,6 @@ impl GlobalState {
lockfile,
maybe_import_map,
compiler_starts: AtomicUsize::new(0),
compile_lock: AsyncMutex::new(()),
};
Ok(Arc::new(global_state))
}
......@@ -116,10 +113,6 @@ impl GlobalState {
) -> Result<(), AnyError> {
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(
self.file_fetcher.clone(),
maybe_import_map,
......@@ -180,8 +173,6 @@ impl GlobalState {
g.write()?;
}
drop(compile_lock);
Ok(())
}
......@@ -195,17 +186,11 @@ impl GlobalState {
module_specifier: ModuleSpecifier,
_maybe_referrer: Option<ModuleSpecifier>,
) -> Result<CompiledModule, AnyError> {
let module_specifier = module_specifier.clone();
let out = self
.file_fetcher
.fetch_cached_source_file(&module_specifier, Permissions::allow_all())
.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
let was_compiled = match out.media_type {
MediaType::TypeScript | MediaType::TSX | MediaType::JSX => true,
......@@ -237,8 +222,6 @@ impl GlobalState {
}
};
drop(compile_lock);
Ok(compiled_module)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册