Fixed a very nasty deadlock

This commit is contained in:
2026-01-22 20:56:02 +01:00
parent f38193edcc
commit b9f1bb74d7
21 changed files with 506 additions and 355 deletions

View File

@@ -63,7 +63,7 @@ impl Root {
pub async fn add_parsed(&self, parsed: &ParsedModule, pars_prefix: Sym) -> Self {
let mut ref_this = self.0.write().await;
let this = &mut *ref_this;
let mut deferred_consts = HashMap::new();
let mut deferred_consts = Vec::new();
let consts = this.consts.clone();
let mut tfpctx = FromParsedCtx {
pars_root: parsed,
@@ -86,7 +86,7 @@ impl Root {
.expect("Merge conflict between parsed and existing module");
let new = Root(Rc::new(RwLock::new(RootData { root, consts, ctx: this.ctx.clone() })));
*this.ctx.root.write().await = new.downgrade();
for (path, (sys_id, pc_id)) in deferred_consts {
for (path, sys_id, pc_id) in deferred_consts {
let sys = this.ctx.system_inst(sys_id).await.expect("System dropped since parsing");
let api_expr = sys.client().request(api::FetchParsedConst(sys.id(), pc_id)).await.unwrap();
let expr = Expr::from_api(&api_expr, PathSetBuilder::new(), this.ctx.clone()).await;
@@ -383,7 +383,7 @@ pub struct FromParsedCtx<'a> {
root: &'a Module,
ctx: &'a Ctx,
consts: &'a MemoMap<Sym, Expr>,
deferred_consts: &'a mut HashMap<Sym, (api::SysId, api::ParsedConstId)>,
deferred_consts: &'a mut Vec<(Sym, api::SysId, api::ParsedConstId)>,
}
impl Tree for Module {
@@ -435,7 +435,7 @@ impl MemberKind {
async fn from_parsed(parsed: &ParsedMemberKind, path: Sym, ctx: &mut FromParsedCtx<'_>) -> Self {
match parsed {
ParsedMemberKind::Const(id, sys) => {
ctx.deferred_consts.insert(path, (sys.id(), *id));
ctx.deferred_consts.push((path, sys.id(), *id));
MemberKind::Const
},
ParsedMemberKind::Mod(m) =>