
Hi,
----- Original Message -----
From: "Anthony Williams"
"vicente.botet"
writes: cowwoc wrote:
I am registering boost::this_thread::at_thread_exit() against one of my threads. When the main thread exits using "return 0" the at_thread_exit hook never gets invoked. Is this normal?
If you call exit() then thread exit handlers are not called. "return 0" in main() is the same as calling exit(0), so thread exit handlers are not called.
Anthony, I've see that you have started to integrate the patch for the thread attributes. Do you plan to integrate this patch also?
No.
If you call pthread_exit(0) from main() then thread exit handlers *will* be called. Of course, this doesn't exit the program until all other threads have terminated, whereas "return 0" kills the other threads.
Unfortunately, after rereading the patch I proposed, I recognize the patch don't works if there are other external threads in the programm as in patch stores only the last external thread context. Calling pthread_exit(0) on a pthread thread is natural, but the main thread is no created as a pthread, so this call is not portable. Do you think that we need a portable function boost::exit that will call to pthread_exit? With the current implementation we don't have any error when we call at_thread_exit on an external thread. This has as consequence that the destructors of the TSS are not called. This is a severe restriction from my point of view. Do you have a portable solution? Best, Vicente