3 ms·
Switching stacks isn’t the difficult part, it’s the related stack memory management.
by layer8 3y ago
Switching stacks isn’t the difficult part, it’s the related stack memory management.
- samsquire 3y agoCould you explain more and elaborate? The previous coroutine state needs to be recovered onto the stack and registers for the coroutine to function correctly from its previous point. Temporal memoizes API calls and replays the same function deterministically, so it doesn't attempt to jump into half way into a function, that a coroutine could do.
- fanf2 3y agoSwitching stacks is just longjmp(). Memory management for stacks has tricky questions about how much address space to reserve for each stack and how to ensure there are guard pages to catch stack overflows. Or you can YOLO it https://dotat.at/@/2010-01-22-coroutines-in-less-than-20-lines-of-standard-c.html https://dotat.at/@/2010-01-22-coroutines-in-less-than-20-lin...