mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 02:39:20 +00:00
Update promise.rs
This commit is contained in:
parent
461e91703a
commit
5508f652fc
1 changed files with 8 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::fmt;
|
||||
use std::thread::{current, JoinHandle, ThreadId};
|
||||
|
||||
use erg_common::consts::DEBUG_MODE;
|
||||
use erg_common::consts::{DEBUG_MODE, SINGLE_THREAD};
|
||||
use erg_common::dict::Dict;
|
||||
use erg_common::pathutil::NormalizedPathBuf;
|
||||
use erg_common::shared::Shared;
|
||||
|
@ -169,12 +169,19 @@ impl SharedPromises {
|
|||
}
|
||||
|
||||
pub fn join(&self, path: &NormalizedPathBuf) -> std::thread::Result<()> {
|
||||
if !self.graph.entries().contains(path) {
|
||||
return Err(Box::new(format!("not registered: {path}")));
|
||||
}
|
||||
if self.graph.ancestors(path).contains(&self.root) {
|
||||
// cycle detected, `self.path` must not in the dependencies
|
||||
// Erg analysis processes never join ancestor threads (although joining ancestors itself is allowed in Rust)
|
||||
// self.wait_until_finished(path);
|
||||
return Ok(());
|
||||
}
|
||||
if SINGLE_THREAD {
|
||||
assert!(self.is_joined(path));
|
||||
return Ok(());
|
||||
}
|
||||
// Suppose A depends on B and C, and B depends on C.
|
||||
// In this case, B must join C before A joins C. Otherwise, a deadlock will occur.
|
||||
let children = self.graph.children(path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue