3 ms·
This is a good time to reiterate my idea that I call "stacking the stack" (like stacking the deck in card games). The idea is that you transform a simple alter
by phaedrus 7y ago
This is a good time to reiterate my idea that I call "stacking the stack" (like stacking the deck in card games). The idea is that you transform a simple alternation between coroutineA and coroutineB into nested method calls, methodA(continuationB) and methodB(continuationA). This way the local context of A and B are live on the stack for debugging.
Of course there would be a limit of depth, but there's always the option to pass an empty continuation and allow the stack to unwind. Since they are coroutines they don't care if you unwind the stack and wind it back up. What I mean is the stack could look like "A-B-A-B-A-B" or "A-B .. A-B .. A-B" or "A .. B .. A .." it doesn't matter. For release build (not debugging) you would just set the depth to 1 and have normal non-nested coroutines.
I can implement this with macros (you wrap your return statements and your co_xxxx statements with a macro) using hand-rolled coroutines. I haven't yet gotten familiar enough into C++ std coroutines to implement it there or see if they allow it to be done without macros.
- cryptonector 7y agoAka, tracing.