4 ms·
One cool thing you can do is to manage the numbers in the case manually, eg. #define LC_SET(s,num) s = num; case num: This will let you serialize the state
by edflsafoiewq 6y ago
One cool thing you can do is to manage the numbers in the case manually, eg.
#define LC_SET(s,num) s = num; case num:
This will let you serialize the state s, modify the program, recompile and reload s, and have it resume at the desired point.
- exDM69 6y agoYou could take this one step further by using the __COUNTER__ macro to generate unique numbers in the preprocessor. Alas, this isn't a part of the standard (iirc), so you need to depend on compiler-specific features.
- edflsafoiewq 6y agoWhat I'm thinking of is modifying it like this LC_SET(s,0) A + LC_SET(s,2) + C LC_SET(s,1) B When the number for each resume point is explicit instead of automatic, you can edit the source code while controling where any existing suspended coroutines will resume at.