4 ms·
> That is in the first case my function must be of a type that can be stopped and continued and I need to save its state somewhere. And that state is saved in
by endorphine 5y ago
> That is in the first case my function must be of a type that can be stopped and continued and I need to save its state somewhere.
And that state is saved in the heap, I presume? Can you provide a concrete example perhaps?
I get that the state in case of green threads (Goroutines for example) is saved in the call stack itself. Where all this is saved in async/await?
- gpderetta 5y agoThe typical implementation of async/await need to store (the equivalent of) a single activation frame (as opposed to a stack of activation frames). This is normally stored separately on the heap, but it can be embedded in some other (heap allocated object) or even stored directly on the stack of some thread, depending on language, usage patterns and optimization capabilites.