On Wed Jul 27 15:39:08 2022 +0000, Torge Matthies wrote:
because C++ objects are not managing memory used to store class structure
We are though. We are the ones calling operator_new. I don't see why we can't reference-count our allocated instances. I also don't see how moving the Context creation to TaskScheduler would work and how it would help, could you elaborate please? And I'm not sure how I can test who manages the Contexts.
I would like to see the tests for finishing the main thread while task collection is still executing.
I'm not saying that code like yours will not work. I'm saying that you shouldn't write anything like this while programming in C++. If it's really needed, it should be done by different class that creates and destroys the class (manages it's lifetime). And the only sensible place I can see now is the scheduler class. I really doubt that anything like ref-counting is done in native implementation.