Concurrency
Document my current understanding of some concepts in concurrency.
Continuation: Save the current task, move on to another task, and come back later. It’s merely one high level concept, and doesn’t say anything about implementation.
Coroutine: It’s should be compared with subroutine, and the key difference between them is that coroutine starts from previous suspension point instead of the first statement as in subroutine. It’s apparent that coroutine captures the idea of continuation.
Fiber: It’s more viewed as the implementation of coroutine. In other words, coroutine is built on top of fiber. Lua exposes coroutine on the language level, while Ruby implement the same functionality using fiber underneath.
Generator: It’s one limited variant of coroutine in that it could only jump back to its caller while coroutine could yield to anywhere.