Home‎ > ‎Lockfree Algorithms‎ > ‎Tips & Tricks‎ > ‎

Thread Completion Notifications

DllMain thread start/end notifications without a DLL
DLL_PROCESS_ATTACH
DLL_PROCESS_DETACH
DLL_THREAD_ATTACH
DLL_THREAD_DETACH

pthread_key_create - destructor



typedef DWORD rl_tss_slot_t;
static void (*rl_tss_dtor)();
static __declspec(thread) int volatile tls_initializer;



void __stdcall on_tls_callback(void* hinst, unsigned long reason, void* unused)
{
    (void)hinst;
    (void)unused;
    if (reason == 3 && rl_tss_dtor)
        rl_tss_dtor();
}

#pragma data_seg(push, old_seg)
#ifdef RL_M32
#   pragma data_seg(".CRT$XLB")
#else
#   pragma const_seg(".CRT$XLB")
#endif
__declspec(dllexport) void (__stdcall * volatile p_on_tls_callback)(void*, unsigned long, void*) = on_tls_callback;
#pragma data_seg(pop, old_seg)

http://svn.boost.org/svn/boost/trunk/libs/thread/src/win32/tss_pe.cpp


Comments