Boost logo

Boost Users :

Subject: Re: [Boost-users] at_thread_exit() never getting called
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-11-02 05:04:49


cowwoc <cowwoc_at_[hidden]> writes:

> Bugzilla from anthony.ajw_at_[hidden] wrote:
>>
>> cowwoc <cowwoc_at_[hidden]> writes:
>>
>>> 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.
>>
>> OK, I'll update the documentation.
>
> I'd rather you fix the undesirable behavior instead...

OK, what is your desired behaviour in these circumstances?

(1) main() thread uses at_thread_exit() and then main() returns

(2) main() thread uses at_thread_exit() and calls exit()

(3) main() thread uses at_thread_exit(). *Another* thread calls exit()

(4) *another* thread uses at_thread_exit(). main() returns

(5) *another* thread uses at_thread_exit(). main() calls exit()

(6) *another* thread uses at_thread_exit() and then calls exit()

Note that returning from main() is the same as calling exit(), and
abruptly terminates all threads.

Anthony

-- 
Author of C++ Concurrency in Action | http://www.manning.com/williams
just::thread C++0x thread library   | http://www.stdthread.co.uk
Just Software Solutions Ltd         | http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

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