I'm planning to use libaco in C++, but I need some clarifications about those 3 scenarios, whether they are not UB and will work correctly.
Creating a coroutine with a non main coroutine as the "main"/parent parameter. So when I use aco_create to create non-main co A, and then pass the resulting coroutine into another aco_create call to create B, as the main co parameter, it seems to work fine. i.e. B yields to A, then A can yield to main. Is this valid though?
Can there be 2 main coroutines in a single thread?
Can aco_exit() be called from a C++ destructor? So I've noticed that aco_exit() causes C++ destructors in a coroutine NOT to fire, which is a problem. As a solution I found out that creating a dummy object at the beginning of the function, which calls aco_exit() as its dtor, actually lets other destructors to fire before aco_exit, and it works even with a return statement, without invoking the "last word" crash.
I'm planning to use libaco in C++, but I need some clarifications about those 3 scenarios, whether they are not UB and will work correctly.