I think a common use of this will be a main function (mbed_start) that will spin up some RTOS stuff, wait for some time/wait for the tests to finish, and then exit everything. We could provide a "graceful shutdown function" that will either 1. join all threads but idle and exit, or 2. exit all functions and do stack unwinding (as well as deallocate the thread structures).
Alternatively, because the stack gets unwinded when exit is called, we could just clean up in the destructor of ThreadDispatcher, which is allocated statically and will hence be destroyed (I think - Valgrind only says that pthread memory is leaked).
I think a common use of this will be a
mainfunction (mbed_start) that will spin up some RTOS stuff, wait for some time/wait for the tests to finish, and then exit everything. We could provide a "graceful shutdown function" that will either 1. join all threads but idle and exit, or 2. exit all functions and do stack unwinding (as well as deallocate the thread structures).Alternatively, because the stack gets unwinded when
exitis called, we could just clean up in the destructor ofThreadDispatcher, which is allocated statically and will hence be destroyed (I think - Valgrind only says that pthread memory is leaked).