Boost logo

Boost Users :

Subject: Re: [Boost-users] at_thread_exit() never getting called
From: Peter Dimov (pdimov_at_[hidden])
Date: 2009-11-08 09:26:19


cowwoc wrote:
> Peter Dimov-5 wrote:
>>
>> You can't use an at_thread_exit hook registered from within a thread
>> to shut
>> down this same thread; this is circular. If you want to shut down a
>> thread when exit() is called or when main returns, use atexit, or a
>> destructor of a
>> static variable. I don't see how at_thread_exit could help in this
>> case, although of course I may be misunderstanding something.
>
> Part of the problem is that neither atexit() or at_thread_exit()
> explicitly specify which thread the hook function will get invoked
> on...

atexit handlers (and global/static variable destructors) are invoked by the
thread that calls exit() (or returns from main). at_thread_exit handlers
(and thread-specific variable destructors) should be invoked by the thread
that called at_thread_exit, after it exits from its thread function.


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