3 ms·
Goroutines aren't coroutines. This isn't a nitpick, it's pretty essential to understanding the goals and non-goals of Neco. Coroutines are a control-flow primi
by samatman 3y ago
Goroutines aren't coroutines. This isn't a nitpick, it's pretty essential to understanding the goals and non-goals of Neco.
Coroutines are a control-flow primitive which allows for a lot of useful things, including advancing program state while a coroutine waits on a syscall, generators, iterators, producer-consumer patterns with channels, and combinations of these things. They generalize function calls, or structure goto, if you prefer.
Some of these applications are glossed as concurrent, particularly their use to free the thread when execution blocks, but all of them are single-threaded. Goroutines are preëmptively scheduled, and can be relocated between threads transparently. That isn't really a coroutine, which is why they have a different name.
The README has some notes on how to use Neco coroutines in a multithreaded environment. It's basically how you'd run execution paths of multiple function calls on several threads, because coroutines are an orthogonal concern to threads.