4 ms·
From the existing explanations, I’ve deduced that coroutines are a form of continuation based coopetative multitasking. Is it possible to “restart” the sequence
by smallstepforman 6y ago
From the existing explanations, I’ve deduced that coroutines are a form of continuation based coopetative multitasking. Is it possible to “restart” the sequence, and how would this be done?
- gpderetta 6y agoAs far as I understand, they are one-shot continuations, so no, they are not restartable unfortunately. I believe at some point one proposal had copyable (and hence multi-shot) continuations, but the proposal had other issues.
- smallstepforman 6y agoThanks for the quality response. Without restarts, it limits the use cases.
- sesuximo 6y agoThere are two ways you can restart with the standard interface: - create a new task (start over) and maybe delete the old task - implement the task as a generator that can repeatedly yield values I think this is as good as you can hope for without lots of other interfaces (and since you can implement all the promise types yourself, you can do that too).