Boost logo

Boost Users :

Subject: [Boost-users] disabling automatic thread-local storage cleanup in boost::thread
From: Sarah Tappon (sarah_tappon_at_[hidden])
Date: 2012-04-12 20:23:26


I would like to use boost::thread (static library) in a DLL project that
also includes some managed C++. Thus I am attempting to disable the
automatic TLS cleanup, since the TLS callbacks it uses are not compatible
with managed code.

I have found references to two methods of doing this:
1) Define tss_cleanup_implemented() to prevent the automatic cleanup code
from being linked in:
http://lists.boost.org/Archives/boost/2007/11/130440.php
2) Build the thread library without tss_pe.cpp:
http://boost.2283326.n4.nabble.com/Using-new-threads-link-issues-td2637128.html

My questions are:
1) Are these two methods functionally equivalent?
2) How exactly does defining tss_cleanup_implemented prevent the cleanup
code from being linked in? Is the idea that if a definition exists locally
the linker won't go looking for one in the library and thus won't link the
cleanup code either? When I define extern "C" void
tss_cleanup_implemented(void){} within my project in the global namespace,
I get linker errors about multiply defined symbols (LNK2005, LNK1169) --
are there other linker settings I need to change in order for it to work?
I'm using Visual Studio 2008.

Finally, I just want to confirm that once I've disabled the automatic
cleanup, I only need to call on_thread_exit() from threads launched through
the native API that use boost::thread functionality like
thread_specific_ptr. If the application only launches threads through
boost, I just need to call on_process_enter/exit in main. Correct?

Thanks,
Sarah



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