From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-02-18 10:09:11


--- In boost_at_y..., "ajp_m" <a.maclean_at_a...> wrote:
> A colleague of mine found the problem (many thanks Mike!).
>
> I did not compile the thread library as a DLL (silly me!).
> Consequently, PROCESS_ATTACH in threadmon.cpp was not allocating
the
> key!
>
> i/e. in this section of code:
> BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID)
> {
> switch (reason)
> {
> case DLL_PROCESS_ATTACH:
> InitializeCriticalSection(&cs);
> key = TlsAlloc();
> break;
> ...
>
> Of course this begs the question:
> Is it possible to modify the code so that if it is not compiled as
a
> DLL the code will still function correctly?

The actual build process compiles most of the library as a static
link library, but the threadmon stuff has to be in a DLL,
unfortunately. This is a consequence of the Win32 MT design where
DllMain() is the only mechanism that allows you to cleanup thread
resources.

Bill Kempf