mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 04:09:05 +00:00
fix(els): SharedPromises::join bug
This commit is contained in:
parent
c34e013658
commit
b2b7f9cfd0
3 changed files with 14 additions and 9 deletions
|
@ -73,7 +73,7 @@ impl Context {
|
||||||
}
|
}
|
||||||
if self.shared.is_some() && self.promises().is_registered(&path) && !self.mod_cached(&path)
|
if self.shared.is_some() && self.promises().is_registered(&path) && !self.mod_cached(&path)
|
||||||
{
|
{
|
||||||
let _result = self.promises().join(&path);
|
let _result = self.promises().join(&path, &self.cfg);
|
||||||
}
|
}
|
||||||
self.opt_mod_cache()?
|
self.opt_mod_cache()?
|
||||||
.raw_ref_ctx(&path)
|
.raw_ref_ctx(&path)
|
||||||
|
|
|
@ -3913,9 +3913,13 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
|
||||||
self.lint(&hir, mode);
|
self.lint(&hir, mode);
|
||||||
if &self.module.context.name[..] == "<module>" || ELS {
|
if &self.module.context.name[..] == "<module>" || ELS {
|
||||||
if ELS {
|
if ELS {
|
||||||
self.module.context.shared().promises.join_children();
|
self.module
|
||||||
|
.context
|
||||||
|
.shared()
|
||||||
|
.promises
|
||||||
|
.join_children(&self.cfg);
|
||||||
} else {
|
} else {
|
||||||
self.module.context.shared().promises.join_all();
|
self.module.context.shared().promises.join_all(&self.cfg);
|
||||||
}
|
}
|
||||||
let errs = self.module.context.shared().errors.take();
|
let errs = self.module.context.shared().errors.take();
|
||||||
let warns = self.module.context.shared().warns.take();
|
let warns = self.module.context.shared().warns.take();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::thread::{current, JoinHandle, ThreadId};
|
use std::thread::{current, JoinHandle, ThreadId};
|
||||||
|
|
||||||
|
use erg_common::config::ErgConfig;
|
||||||
use erg_common::consts::{DEBUG_MODE, PARALLEL};
|
use erg_common::consts::{DEBUG_MODE, PARALLEL};
|
||||||
use erg_common::dict::Dict;
|
use erg_common::dict::Dict;
|
||||||
use erg_common::pathutil::NormalizedPathBuf;
|
use erg_common::pathutil::NormalizedPathBuf;
|
||||||
|
@ -178,7 +179,7 @@ impl SharedPromises {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn join(&self, path: &NormalizedPathBuf) -> std::thread::Result<()> {
|
pub fn join(&self, path: &NormalizedPathBuf, cfg: &ErgConfig) -> std::thread::Result<()> {
|
||||||
if !self.graph.entries().contains(path) {
|
if !self.graph.entries().contains(path) {
|
||||||
return Err(Box::new(format!("not registered: {path}")));
|
return Err(Box::new(format!("not registered: {path}")));
|
||||||
}
|
}
|
||||||
|
@ -189,7 +190,7 @@ impl SharedPromises {
|
||||||
// self.wait_until_finished(path);
|
// self.wait_until_finished(path);
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
if !self.graph.deep_depends_on(¤t, path) {
|
if !cfg.mode.is_language_server() && !self.graph.deep_depends_on(¤t, path) {
|
||||||
// no relation, so no need to join
|
// no relation, so no need to join
|
||||||
if DEBUG_MODE {
|
if DEBUG_MODE {
|
||||||
panic!("not depends on: {current} -> {path}");
|
panic!("not depends on: {current} -> {path}");
|
||||||
|
@ -230,7 +231,7 @@ impl SharedPromises {
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn join_children(&self) {
|
pub fn join_children(&self, cfg: &ErgConfig) {
|
||||||
let cur_id = std::thread::current().id();
|
let cur_id = std::thread::current().id();
|
||||||
let mut paths = vec![];
|
let mut paths = vec![];
|
||||||
for (path, promise) in self.promises.borrow().iter() {
|
for (path, promise) in self.promises.borrow().iter() {
|
||||||
|
@ -240,14 +241,14 @@ impl SharedPromises {
|
||||||
paths.push(path.clone());
|
paths.push(path.clone());
|
||||||
}
|
}
|
||||||
for path in paths {
|
for path in paths {
|
||||||
let _result = self.join(&path);
|
let _result = self.join(&path, cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn join_all(&self) {
|
pub fn join_all(&self, cfg: &ErgConfig) {
|
||||||
let paths = self.promises.borrow().keys().cloned().collect::<Vec<_>>();
|
let paths = self.promises.borrow().keys().cloned().collect::<Vec<_>>();
|
||||||
for path in paths {
|
for path in paths {
|
||||||
let _result = self.join(&path);
|
let _result = self.join(&path, cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue