Boost logo

Boost Users :

Subject: Re: [Boost-users] at_thread_exit() never getting called
From: cowwoc (cowwoc_at_[hidden])
Date: 2009-10-29 09:50:32


Bugzilla from anthony.ajw_at_[hidden] wrote:
>
> "vicente.botet" <vicente.botet_at_[hidden]> 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.
>
> Anthony
>

Anthony,

The documentation is far from obvious on this point. It just reads: "This
copy is invoked when the current thread exits (even if the thread has been
interrupted)."

Source:
http://www.boost.org/doc/libs/1_40_0/doc/html/thread/thread_management.html#thread.thread_management.this_thread.atthreadexit

I expect the function to get invoked if the thread exits for *any* reason,
not just because the documentation says so but also because it's what I want
from a coding point of view.

Thanks,
Gili

-- 
View this message in context: http://www.nabble.com/at_thread_exit%28%29-never-getting-called-tp26053513p26113396.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net