Boost logo

Boost Users :

Subject: Re: [Boost-users] at_thread_exit() never getting called
From: cowwoc (cowwoc_at_[hidden])
Date: 2009-11-08 17:45:02


Peter Dimov-5 wrote:
>
> cowwoc wrote:
>> One of my threads has the following logic:
>>
>> {
>> at_thread_exit(myHook);
>> while (!shutdownRequested)
>> {
>> // do stuff
>> }
>> }
>>
>> myHook()
>> {
>> shutdownRequested = true;
>> }
>>
>> Following your scenario, doesn't this mean that the shutdown
>> hook will never get executed? What will happen? Will exit() hang
>> forever?
>
> It will never get executed. The hook is executed AFTER the thread exits.
>

So how do you propose I implement the use-case I mentioned?

Peter Dimov-5 wrote:
>
> exit() will not hang, it will just terminate the thread (and all other
> threads) as its very last step (after invoking the atexit handlers and
> global/static destructors).
>

But what happens if one of the handlers is itself waiting for the thread to
shut down?
Also, is at_thread_exit() implemented as an atexit() handler under the hood?
If not, how do you prevent it from killing the hook functions prematurely?

Thanks,
Gili

-- 
View this message in context: http://old.nabble.com/at_thread_exit%28%29-never-getting-called-tp26053513p26258828.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