Thank you very much for your quick and your professional answer. You are right. I am linking statically against boost.Thread.

I want to avoid using the dll Version so I already got a  workaround:
i just use the DLL_THREAD_DETACH event within the  DllMain function and call the cleanup stuff manually if the thread_specific_ptr.get() != Null
this seems to work fine. Any objections?

Is there any FAQ for boost threads what works and what not? Something like does and don`ts? I think this would be quite usefull both for beginners and skilled people.

Rudi


2008/9/4 Anthony Williams <anthony@justsoftwaresolutions.co.uk>
At Thu 04 Sep 2008 13:50:20 BST, Rudi Lindl <rudi.lindl@web.de> wrote:

I have trouble with a clean up function within a dll.

[snip code]


But the cleanup funtion is not called. Any Idea?
If i move the myDllFuntion,  void detach_thread funtion and the declaration
of the boost::thread_specific_ptr<unsigned int>
current_thread_index(&detach_thread) from the dll to the file where the main
funtions is defined everything works as expected.

I'm going to make a stab in the dark and guess that you're linking statically against Boost.Thread from both the main app and the DLL? If so, then this is the reason: the DLL cannot hook the TLS cleanup into the boost::thread data structure from the main app, so the cleanup isn't called.

If you *are* using the DLL version of Boost.Thread, then I'll have to investigate further.

Anthony
--
Anthony Williams            | Just Software Solutions Ltd
Custom Software Development | http://www.justsoftwaresolutions.co.uk
Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL


_______________________________________________
threads-devel mailing list
threads-devel@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/threads-devel