本文整理汇总了C++中TlsFree函数的典型用法代码示例。如果您正苦于以下问题:C++ TlsFree函数的具体用法?C++ TlsFree怎么用?C++ TlsFree使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TlsFree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tsrm_shutdown
/* Shutdown TSRM (call once for the entire process) */
TSRM_API void tsrm_shutdown(void)
{
int i;
if (tsrm_tls_table) {
for (i=0; i<tsrm_tls_table_size; i++) {
tsrm_tls_entry *p = tsrm_tls_table[i], *next_p;
while (p) {
int j;
next_p = p->next;
for (j=0; j<p->count; j++) {
if (p->storage[j]) {
if (resource_types_table && !resource_types_table[j].done && resource_types_table[j].dtor) {
resource_types_table[j].dtor(p->storage[j], &p->storage);
}
free(p->storage[j]);
}
}
free(p->storage);
free(p);
p = next_p;
}
}
free(tsrm_tls_table);
tsrm_tls_table = NULL;
}
if (resource_types_table) {
free(resource_types_table);
resource_types_table=NULL;
}
tsrm_mutex_free(tsmm_mutex);
tsmm_mutex = NULL;
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Shutdown TSRM"));
if (tsrm_error_file!=stderr) {
fclose(tsrm_error_file);
}
#if defined(GNUPTH)
pth_kill();
#elif defined(PTHREADS)
pthread_setspecific(tls_key, 0);
pthread_key_delete(tls_key);
#elif defined(TSRM_WIN32)
TlsFree(tls_key);
#endif
}
示例2: RBT_on_process_exit
extern "C" RCF_BOOST_THREAD_DECL void RBT_on_process_exit(void)
{
boost::call_once(init_threadmon_mutex, once_init_threadmon_mutex);
boost::mutex::scoped_lock lock(*threadmon_mutex);
#ifndef __MINGW32__
BOOST_ASSERT(attached_thread_count == 0);
#endif
//Free the tls slot if one was allocated.
if (tls_key != invalid_tls_key)
{
TlsFree(tls_key);
tls_key = invalid_tls_key;
}
}
示例3: DllMain
/*************************************************************************
* SHLWAPI DllMain
*
* NOTES
* calling oleinitialize here breaks some apps.
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
{
TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
shlwapi_hInstance = hinstDLL;
SHLWAPI_ThreadRef_index = TlsAlloc();
break;
case DLL_PROCESS_DETACH:
if (fImpLoad) break;
if (SHLWAPI_ThreadRef_index != TLS_OUT_OF_INDEXES) TlsFree(SHLWAPI_ThreadRef_index);
break;
}
return TRUE;
}
示例4: kmm_exit
KHMEXP void KHMAPI kmm_exit(void)
{
kmm_module_i * m;
kmm_plugin_i * p;
EnterCriticalSection(&cs_kmm);
p = kmm_listed_plugins;
while(p) {
kmm_plugin_i * pn;
pn = LNEXT(p);
/* plugins that were never resolved should be kicked off the
list. Flipping the refcount will do that if no other
references exist for the plugin. The plugins that were
waiting for unresolved dependencies will automatically get
freed when the placeholders and other plugins get freed. */
if(p->state == KMM_PLUGIN_STATE_PLACEHOLDER) {
kmm_hold_plugin(kmm_handle_from_plugin(p));
kmm_release_plugin(kmm_handle_from_plugin(p));
}
p = pn;
}
m = kmm_all_modules;
while(m) {
kmm_unload_module(kmm_handle_from_module(m));
m = LNEXT(m);
}
LeaveCriticalSection(&cs_kmm);
WaitForSingleObject(evt_exit, INFINITE);
EnterCriticalSection(&cs_kmm);
kmq_post_thread_quit_message(tid_registrar, 0, NULL);
hash_del_hashtable(hash_plugins);
hash_del_hashtable(hash_modules);
LeaveCriticalSection(&cs_kmm);
TlsFree(tls_kmm);
tls_kmm = 0;
}
示例5: THREAD_CreateKey
/*
* Creates a thread-local key
*/
ThrKey THREAD_CreateKey(ThrClean proc)
{
ASSERT(THREAD_IsInited());
if (THREAD_IsInited()) {
DWORD index = TlsAlloc();
ASSERT(index != TLS_OUT_OF_INDEXES);
if (index != TLS_OUT_OF_INDEXES) {
ThrKey key = MEM_New(struct _ThrKey);
if (key) {
key->index = index;
key->clean = proc;
key->ref = 1;
return key;
}
TlsFree(index);
}
}
示例6: SyncInit
HRESULT SyncInit()
{
if (g_bInited)
return S_OK;
g_tlsiLdrLoadDllRecursion = TlsAlloc();
if (g_tlsiLdrLoadDllRecursion == TLS_OUT_OF_INDEXES)
return E_OUTOFMEMORY;
if (!HookBaseInit())
{
TlsFree(g_tlsiLdrLoadDllRecursion);
return E_FAIL;
}
return S_OK;
}
示例7: DllMain
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
TRACE("(%p, %d, %p)\n", instance, reason, reserved);
switch (reason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
{
SYSTEM_INFO sysinfo;
if ((vcomp_context_tls = TlsAlloc()) == TLS_OUT_OF_INDEXES)
{
ERR("Failed to allocate TLS index\n");
return FALSE;
}
GetSystemInfo(&sysinfo);
vcomp_max_threads = sysinfo.dwNumberOfProcessors;
vcomp_num_threads = sysinfo.dwNumberOfProcessors;
break;
}
case DLL_PROCESS_DETACH:
{
if (reserved) break;
if (vcomp_context_tls != TLS_OUT_OF_INDEXES)
{
vcomp_free_thread_data();
TlsFree(vcomp_context_tls);
}
break;
}
case DLL_THREAD_DETACH:
{
vcomp_free_thread_data();
break;
}
}
return TRUE;
}
示例8: DllMain
BOOL APIENTRY DllMain(HMODULE hm, DWORD reason, LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
InitializeCriticalSection(&threadLock);
threadsDone = CreateEvent(NULL, TRUE, FALSE, NULL);
break;
case DLL_PROCESS_DETACH:
terminating = true;
if (reserved != NULL) {
// process exit(): threads are stopped arbitrarily and
// possibly in an inconsistent state. Not even threadLock
// can be trusted. All static destructors have been
// called at this point and any resources this unit knows
// about will be released as part of process tear down by
// the OS. Accordingly, do nothing.
return TRUE;
}
else {
// FreeLibrary(): threads are still running and we are
// encouraged to clean up to avoid leaks. Mostly we just
// want any straggler threads to finish and notify
// threadsDone as the last thing they do.
while (1) {
{
ScopedCriticalSection l(threadLock);
if (runningThreads == 0)
break;
ResetEvent(threadsDone);
}
WaitForSingleObject(threadsDone, INFINITE);
}
if (tlsIndex != TLS_OUT_OF_INDEXES)
TlsFree(getTlsIndex());
CloseHandle(threadsDone);
DeleteCriticalSection(&threadLock);
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
示例9: BtrOnProcessDetach
BOOL
BtrOnProcessDetach(
VOID
)
{
InterlockedExchange(&BtrUnloading, TRUE);
if (FlagOn(BtrFeatures, FeatureLibrary)) {
return TRUE;
}
if (FlagOn(BtrFeatures, FeatureLocal|FeatureRemote)) {
if (BtrTlsIndex != TLS_OUT_OF_INDEXES) {
TlsFree(BtrTlsIndex);
}
}
return TRUE;
}
示例10: vlc_threadvar_delete
void vlc_threadvar_delete (vlc_threadvar_t *p_tls)
{
struct vlc_threadvar *var = *p_tls;
EnterCriticalSection(&super_mutex);
if (var->prev != NULL)
var->prev->next = var->next;
if (var->next != NULL)
var->next->prev = var->prev;
else
vlc_threadvar_last = var->prev;
LeaveCriticalSection(&super_mutex);
TlsFree (var->id);
free (var);
}
示例11: onProcessDestruction
void onProcessDestruction() throw ( ::jace::JNIException ) {
#ifdef SUPPORTS_PTHREADS
int rc = pthread_key_delete( CLASSLOADER_KEY );
if ( rc != 0 ) {
std::string msg = "JNIHelper::setClassLoader()\n"
"thread_key_delete() returned " + std::to_string( rc ) + ".";
throw JNIException( msg );
}
#elif _WIN32
BOOL rc = TlsFree( CLASSLOADER_KEY );
if ( !rc ) {
std::string msg = "JNIHelper::setClassLoader()\n"
"TlsFree() returned " + std::to_string( GetLastError() ) + ".";
throw JNIException( msg );
}
#endif
}
示例12: vlc_threadvar_delete
void vlc_threadvar_delete (vlc_threadvar_t *p_tls)
{
struct vlc_threadvar *var = *p_tls;
vlc_mutex_lock (&super_mutex);
if (var->prev != NULL)
var->prev->next = var->next;
if (var->next != NULL)
var->next->prev = var->prev;
else
vlc_threadvar_last = var->prev;
vlc_mutex_unlock (&super_mutex);
TlsFree (var->id);
free (var);
}
示例13: DllMain
/* DLL entry point */
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
BOOL ret=TRUE;
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
set_tls_i(TlsAlloc());
ret = (get_tls_i()!=TLS_OUT_OF_INDEXES);
break;
case DLL_PROCESS_DETACH:
if (get_tls_i()!=TLS_OUT_OF_INDEXES) TlsFree(get_tls_i());
break;
}
return ret;
}
示例14: VThreadBaseGetKey
static VThreadBaseKeyType
VThreadBaseGetKey(void)
{
VThreadBaseKeyType key = Atomic_Read(&vthreadBaseGlobals.key);
if (key == VTHREADBASE_INVALID_KEY) {
VThreadBaseKeyType newKey;
#if defined _WIN32
newKey = TlsAlloc();
ASSERT_NOT_IMPLEMENTED(newKey != VTHREADBASE_INVALID_KEY);
#else
Bool success = pthread_key_create(&newKey,
&VThreadBaseSafeDeleteTLS) == 0;
if (success && newKey == 0) {
/*
* Leak TLS key 0. System libraries have a habit of destroying
* it. See bugs 702818 and 773420.
*/
success = pthread_key_create(&newKey,
&VThreadBaseSafeDeleteTLS) == 0;
}
ASSERT_NOT_IMPLEMENTED(success);
#endif
if (Atomic_ReadIfEqualWrite(&vthreadBaseGlobals.key,
VTHREADBASE_INVALID_KEY,
newKey) != VTHREADBASE_INVALID_KEY) {
/* Race: someone else init'd */
#if defined _WIN32
TlsFree(newKey);
#else
pthread_key_delete(newKey);
#endif
}
key = Atomic_Read(&vthreadBaseGlobals.key);
ASSERT(key != VTHREADBASE_INVALID_KEY);
}
return key;
}
示例15: TlsFree
BOOL
Module::Detach()
{
ErrorInfo::Fini();
if (m_dwTlsIndex != TLS_OUT_OF_INDEXES)
{
TlsFree(m_dwTlsIndex);
m_dwTlsIndex = TLS_OUT_OF_INDEXES;
}
if (m_pGIT != NULL)
{
m_pGIT->Release();
m_pGIT = NULL;
}
return TRUE;
}