mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 18:58:30 +00:00
WIP: support cyclic modules
This commit is contained in:
parent
f43b683eda
commit
3e137da0a1
12 changed files with 204 additions and 21 deletions
|
@ -1,3 +1,4 @@
|
|||
use std::fmt;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::thread::{current, JoinHandle, ThreadId};
|
||||
|
||||
|
@ -13,6 +14,17 @@ pub enum Promise {
|
|||
Finished,
|
||||
}
|
||||
|
||||
impl fmt::Display for Promise {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Running { handle, .. } => {
|
||||
write!(f, "running on thread {:?}", handle.thread().id())
|
||||
}
|
||||
Self::Finished => write!(f, "finished"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Promise {
|
||||
pub fn running(handle: JoinHandle<()>) -> Self {
|
||||
Self::Running {
|
||||
|
@ -50,6 +62,16 @@ impl Promise {
|
|||
#[derive(Debug, Clone, Default)]
|
||||
pub struct SharedPromises(Shared<Dict<PathBuf, Promise>>);
|
||||
|
||||
impl fmt::Display for SharedPromises {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "SharedPromises {{ ")?;
|
||||
for (path, promise) in self.0.borrow().iter() {
|
||||
writeln!(f, "{}: {}, ", path.display(), promise)?;
|
||||
}
|
||||
write!(f, "}}")
|
||||
}
|
||||
}
|
||||
|
||||
impl SharedPromises {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue