Concurrency
Concurrency in elz is CSP model. !!! I preparing use pthread & meta programming to create this part, so won't be a part of language spec
let ch = channel<int>()
fn sqare() {
let mut i = 0
loop {
match i {
<100 => break,
i => ch <- i * i
}
}
ch.close()
}
act sqare()
fn main()
act sqare()
loop {
let v = <- ch
match v {
n => println(n),
nil => break
}
}
}
After channel close, it send nil to receiver, so we can judge the state we are meeting to deciding what should we do.
I found some problem about channel system at my Side project redux(for go).
If user call Dispatch in Subscribed function, I want to stop it by give it a panic message.
But whole Dispatch have to Lock. And Subscribed function will be invoked by Dispatch. The problem come, we Lock at the head of Dispatch, but call Dispatch at Subscribe part. We will Lock it again, and cause deadlock. So the check will never executed. So sad.