Making Coroutines More Deterministic in Embedded
Hey!
By overriding the operator new in the promise_type in coroutines you can apparently use your own allocator - there is a pigweed blog on this somewhere. However, if you wanted to use coroutines in embedded with async runtime kinda like embassy in rust instead of an RTOS I want to understand how you “tame” the heap allocation to make it more deterministic.
I am not super familiar with this area….apparently there is no way to get the coroutines size at compile time. In embedded you might wanna make your own pool allocator. For this and not to waste memory it would be good to know the size of the coroutines frames exactly if they are allocator allocated.
So do you introduce a build script for your projects that compiles and records the sizes of the coroutines when they call new with a logger compiled in? Without guessing is this literally the professional way to get some level of certainty? It feels kinda crude :(
There was an open std pdf on getting some decent compile time failure if they exceed a size but as far as I can tell it was never implemented (maybe I am being dumb?) P1365r0.pdf