Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2004-07-16 22:32:56

Michael Glassford wrote:
> I've made some changes to the Boost.Threads static linking support on
> Win32. Previously I had added back support for static linking, but
> without thread-specific storage classes. Now I've added the
> thread-specific storage classes back in, and exposed two functions
> that
> need to be called at the appropriate time:
> The function on_thread_exit() should be called when a thread exists,
> *in
> the context of the exiting thread*. The function on_process_exit()
> should be called when the process exit. If these functions are not
> called at the appropriate time, leaks may occur. If you know you don't
> need tss cleanup, of course you can just omit to call these functions.
> In addition, Boost.Threads static library on Win32 requires the user
> of
> the library to define a function called tss_cleanup_implemented(); if
> it
> is not defined, a link error results. The only purpose of this
> function
> is as a "link-time assertion": the linker error stating that the
> function is missing warns the the user of the necessity of calling the
> cleanup functions. In addition, if Boost.Threads later implements tss
> cleanup in the static library, the linker's duplicate symbol error
> should warn the user that their custom implementation is no longer
> needed.
> Comments?

I like this very much as my reticence to use the thread library was
completely based on the fact that it did not have a static lib version.

While your tss_cleanup_imnplemented() is clever, I wonder if it is really
necessary. The spirit of C++ is usuually to allow the programmer to do the
wrong thing at their peril. Enforcing tss_cleanup_implemented just to warn
the programmer of something which the documentation should make clear is not
something I would do.

I assume you mean above that on_thread_exit should be called when a thread
exits, in the context of the exiting thread.

Boost list run by bdawes at, gregod at, cpdaniel at, john at