ammarbinfaisal / sahl

a programming language with channels and coroutines/threads
MIT License
9 stars 1 forks source link

coroutines scheduler #34

Closed ammarbinfaisal closed 1 year ago

ammarbinfaisal commented 1 year ago

actual go like instead of pthreads

ammarbinfaisal commented 1 year ago

this always runs into a deadlock with the current approach.

// samples/chan.sahl
fun sendvals(c: chan<int>, count: int) {
    let i = 0
    while i < count {
        c <- i
        i = i + 1
    }
}

fun recvvals(c: chan<int>, count: int) {
    let i = 0
    while i < count {
        print(<-c, "\n")
        i = i + 1
    }
}

fun main() {
    let i = 0
    while i < 100 {
        let a = make(chan<int>)
        sahl sendvals(a, 10000)
        sahl recvvals(a, 10000)
        i = i + 1
    }
}
ammarbinfaisal commented 1 year ago

https://github.com/abooishaaq/sahl/issues/34#issuecomment-1682152668 fixed by https://github.com/abooishaaq/sahl/commit/20ca0682e2d12e9f7419385813bda0cfc34690c6#diff-d323447fbf0ed92bf31e6a9e69b4497a7c4338dba360cc577620fc0a42839527R600-R604

ammarbinfaisal commented 1 year ago

closing this