2 ms·
> Unlike coroutines, each cooperative thread has its own stack frame. This seems to be incorrect. See: https://stackoverflow.com/questions/28977302/how-do-sta
by amelius 7y ago
> Unlike coroutines, each cooperative thread has its own stack frame.
This seems to be incorrect. See:
https://stackoverflow.com/questions/28977302/how-do-stackless-coroutines-differ-from-stackful-coroutines https://stackoverflow.com/questions/28977302/how-do-stackles...
> In contrast to a stackless coroutine a stackful coroutine can be suspended from within a nested stackframe.
It seems the author is trying to reinvent stackful coroutines, and calls them "cooperative threads".
- gpderetta 7y agoYou could argue that coroutines as originally specified implied stackless-ness: it was just a generalization of a subroutine that could return (to its immediate caller) multiple times, so at most one stack frame need to be preserved. A better name for stackful coroutines is one-shot continuations.
- byuu 7y agoNo one really agrees on the exact terminology. There are stackful and stackless coroutines, continuations, green threads, fibers, cooperative threads, etc. Generally when people talk about coroutines without a qualification they are meaning the stackless variety. I personally consider a coroutine with a stack frame to be a cooperative thread, but understandably not everyone will agree on naming. The nomenclature hopefully should not affect the broader message of the article though. In any case, I am not so much trying as I already have. C++ does not have stackful coroutines. I implemented them via my libco library and have been using them for over a decade now.