| 1 | // (C) Copyright Michael Glassford 2004. |
|---|
| 2 | // Use, modification and distribution are subject to the |
|---|
| 3 | // Boost Software License, Version 1.0. (See accompanying file |
|---|
| 4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 5 | |
|---|
| 6 | #include <boost/thread/detail/config.hpp> |
|---|
| 7 | |
|---|
| 8 | #if defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) |
|---|
| 9 | |
|---|
| 10 | #include <boost/thread/detail/tss_hooks.hpp> |
|---|
| 11 | |
|---|
| 12 | #define WIN32_LEAN_AND_MEAN |
|---|
| 13 | #include <windows.h> |
|---|
| 14 | |
|---|
| 15 | #if defined(__BORLANDC__) |
|---|
| 16 | extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) |
|---|
| 17 | #else |
|---|
| 18 | extern "C" BOOL WINAPI DllMain(HINSTANCE /*hInstance*/, DWORD dwReason, LPVOID /*lpReserved*/) |
|---|
| 19 | #endif |
|---|
| 20 | { |
|---|
| 21 | switch(dwReason) |
|---|
| 22 | { |
|---|
| 23 | case DLL_PROCESS_ATTACH: |
|---|
| 24 | { |
|---|
| 25 | on_process_enter(); |
|---|
| 26 | on_thread_enter(); |
|---|
| 27 | break; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | case DLL_THREAD_ATTACH: |
|---|
| 31 | { |
|---|
| 32 | on_thread_enter(); |
|---|
| 33 | break; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | case DLL_THREAD_DETACH: |
|---|
| 37 | { |
|---|
| 38 | on_thread_exit(); |
|---|
| 39 | break; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | case DLL_PROCESS_DETACH: |
|---|
| 43 | { |
|---|
| 44 | on_thread_exit(); |
|---|
| 45 | on_process_exit(); |
|---|
| 46 | break; |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | return TRUE; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | extern "C" void tss_cleanup_implemented(void) |
|---|
| 54 | { |
|---|
| 55 | /* |
|---|
| 56 | This function's sole purpose is to cause a link error in cases where |
|---|
| 57 | automatic tss cleanup is not implemented by Boost.Threads as a |
|---|
| 58 | reminder that user code is responsible for calling the necessary |
|---|
| 59 | functions at the appropriate times (and for implementing an a |
|---|
| 60 | tss_cleanup_implemented() function to eliminate the linker's |
|---|
| 61 | missing symbol error). |
|---|
| 62 | |
|---|
| 63 | If Boost.Threads later implements automatic tss cleanup in cases |
|---|
| 64 | where it currently doesn't (which is the plan), the duplicate |
|---|
| 65 | symbol error will warn the user that their custom solution is no |
|---|
| 66 | longer needed and can be removed. |
|---|
| 67 | */ |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | #endif //defined(BOOST_HAS_WINTHREADS) && defined(BOOST_THREAD_BUILD_DLL) |
|---|