• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pthread_key_delete函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pthread_key_delete函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_key_delete函数的具体用法?C++ pthread_key_delete怎么用?C++ pthread_key_delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pthread_key_delete函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: wrap_pthread_key_delete

static int wrap_pthread_key_delete(pthread_key_t key)
{
    /* this is clumsy: having to key_create lessens key_delete's chances
       of being interrupted - test not definite */
    int err2;
    WRAP_START
    while(
        !(err2 = pthread_key_create(&key, NULL))
        &&
        !(err  = pthread_key_delete(key))
    );
    if (err2)
        err = -3; //meaning the dependecy failed
    WRAP_END
}
开发者ID:rofl0r,项目名称:cluts,代码行数:15,代码来源:pthread_eintr.c


示例2: _MXML_FINI

static void
_MXML_FINI(void)
{
  _mxml_global_t	*global;	/* Global data */


  if (_mxml_key != -1)
  {
    if ((global = (_mxml_global_t *)pthread_getspecific(_mxml_key)) != NULL)
      _mxml_destructor(global);

    pthread_key_delete(_mxml_key);
    _mxml_key = -1;
  }
}
开发者ID:Azarien,项目名称:processhacker2,代码行数:15,代码来源:mxml-private.c


示例3: tMPI_Thread_key_delete

int tMPI_Thread_key_delete(tMPI_Thread_key_t key)
{
    int ret;

    ret=pthread_key_delete((key.key->pkey));
    free(key.key);

    if(ret!=0)
    {
        tMPI_Fatal_error(TMPI_FARGS,"Failed to delete thread key, rc=%d.",ret);
        fflush(stderr);
    }
    
    return ret;
}
开发者ID:BradleyDickson,项目名称:ABPenabledGROMACS,代码行数:15,代码来源:pthreads.c


示例4: delete_msgque

void delete_msgque(void  *arg)
{
	msgque_t que = (msgque_t)arg;
    lnode *n;
	if(que->destroy_function){
        while((n = LLIST_POP(lnode*,&que->share_que))!=NULL)
			que->destroy_function((void*)n);
	}
	mutex_destroy(&que->mtx);
	pthread_key_delete(que->t_key);
	free(que);
#ifdef _DEBUG
	printf("on_que_destroy\n");
#endif
}
开发者ID:benjiam,项目名称:KendyNet,代码行数:15,代码来源:msgque.c


示例5: OS_FreeTLSIndex

bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
	if (nIndex == OS_INVALID_TLS_INDEX) {
		assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
		return false;
	}

	//
	// Delete the global pool key.
	//
	if (pthread_key_delete(nIndex) == 0)
		return true;
	else
		return false;
}
开发者ID:dougbinks,项目名称:renderdoc,代码行数:15,代码来源:ossource.cpp


示例6: Test_Thread

rtems_task Test_Thread( rtems_task_argument arg )
{
  void *argument = (void *) arg;
  int sc;

  puts( "Test_Thread - key pthread_setspecific - OK" );
  sc = pthread_setspecific( key, argument );
  rtems_test_assert( !sc );

  puts( "Test_Thread - pthread key delete - OK" );
  sc = pthread_key_delete( key );
  rtems_test_assert( sc == 0 );

  puts( "Test_Thread - exit but don't run key destructors - OK" );
  rtems_task_delete( RTEMS_SELF );
}
开发者ID:AlexShiLucky,项目名称:rtems,代码行数:16,代码来源:init.c


示例7: ENABLE

MachineThreads::~MachineThreads()
{
#if ENABLE(JSC_MULTIPLE_THREADS)
    if (m_threadSpecific) {
        int error = pthread_key_delete(m_threadSpecific);
        ASSERT_UNUSED(error, !error);
    }

    MutexLocker registeredThreadsLock(m_registeredThreadsMutex);
    for (Thread* t = m_registeredThreads; t;) {
        Thread* next = t->next;
        delete t;
        t = next;
    }
#endif
}
开发者ID:BGmot,项目名称:Qt,代码行数:16,代码来源:MachineStackMarker.cpp


示例8: checklock_stop

/** stop checklocks */
void checklock_stop(void)
{
	if(key_created) {
		int i;
		key_deleted = 1;
		if(check_locking_order)
			fclose(thread_infos[0]->order_info);
		free(thread_infos[0]);
		thread_infos[0] = NULL;
		for(i = 0; i < THRDEBUG_MAX_THREADS; i++)
			log_assert(thread_infos[i] == NULL);
			/* should have been cleaned up. */
		LOCKRET(pthread_key_delete(thr_debug_key));
		key_created = 0;
	}
}
开发者ID:Coder420,项目名称:bitmonero,代码行数:17,代码来源:checklocks.c


示例9: wrap_pthread_key_create

static int wrap_pthread_key_create(pthread_key_t *key,
                                   void (*destructor)(void*))
{
    /* this is clumsy: having to key_create lessens key_delete's chances
       of being interrupted - test not definite */
    int err2;
    WRAP_START
    while(
        !(err  = pthread_key_create(key, destructor))
        &&
        !(err2 = pthread_key_delete(*key))
    );
    if (!err && err2)
        err = -3; //meaning the dependecy failed
    WRAP_END
}
开发者ID:rofl0r,项目名称:cluts,代码行数:16,代码来源:pthread_eintr.c


示例10: JNI_OnUnload

JNIEXPORT void JNICALL
JNI_OnUnload(JavaVM *jvm, void *reserved)
{
    JNIEnv *env;

    destroy_native_crash_handler();

    if (jvm->GetEnv((void **) &env, JNI_VERSION))
        return;

    env->DeleteGlobalRef(gfq.clazz);
    env->DeleteGlobalRef(gfq.String.clazz);
    env->DeleteGlobalRef(gfq.IllegalArgumentException.clazz);

    pthread_key_delete(jni_env_key);
}
开发者ID:keyanmca,项目名称:fqrtmpplayer,代码行数:16,代码来源:libfqrtmpjni.cpp


示例11: workaroundHook

/**
 * Simple holder of work-arounds for link-time issues.
 */
void workaroundHook()
{
    pthread_key_t key = {0};
    int ret = pthread_key_create(&key, NULL);
    if (!ret)
    {
        void *ptr = pthread_getspecific(key); // should return NULL
        ret = pthread_setspecific(key, &ptr);
        if (ret)
        {
            // Something went wrong. Since this is a stub, we don't care.
        }

        pthread_key_delete(key);
    }
}
开发者ID:EmuxEvans,项目名称:iotivity,代码行数:19,代码来源:catests.cpp


示例12: main

int main(void)
{
	pthread_t thid1;
	int status;
	
	pthread_key_create(&keyid,NULL);
	
	if (pthread_create(&thid1,NULL,(void *)func2,NULL))
		printf("创建线程1失败\n");

	printf("主线程:%lu\n",pthread_self());
	pthread_join(thid1,(void *)&status);
	pthread_key_delete(keyid);

	return 0;
}
开发者ID:Jungzhang,项目名称:-C-,代码行数:16,代码来源:pthread_key.c


示例13: while

void PoolMemoryAllocator::cleanup()
{
	BlockChainPtr p = s_blocks;
	while(p != 0) {
		BlockChainPtr pNext = p->m_next;
		free(p);
		p = pNext;
	}

#ifndef OGDF_MEMORY_POOL_NTS
#ifdef OGDF_NO_COMPILER_TLS
	pthread_key_delete(s_tpKey);
#endif
	delete s_criticalSection;
#endif
}
开发者ID:SiteView,项目名称:NNMQT,代码行数:16,代码来源:PoolMemoryAllocator.cpp


示例14: git_threads_shutdown

void git_threads_shutdown(void)
{
	if (_tls_init) {
		void *ptr = pthread_getspecific(_tls_key);
		pthread_setspecific(_tls_key, NULL);
		git__free(ptr);
	}

	pthread_key_delete(_tls_key);
	_tls_init = 0;
	git_mutex_free(&git__mwindow_mutex);

	/* Shut down any subsystems that have global state */
	git_hash_global_shutdown();
	git_futils_dirs_free();
}
开发者ID:aep,项目名称:libgit2,代码行数:16,代码来源:global.c


示例15: main

int main()
{
    pthread_t tid[THREAD_NUM];
    int i;
    pthread_key_create(&key, NULL);

#pragma omp parallel for
    for ( i = 0; i < THREAD_NUM; i++ )
        pthread_create(&tid[i], NULL, thread, NULL);
#pragma omp parallel for
    for ( i = 0; i < THREAD_NUM; i++ )
        pthread_join(tid[i], NULL);

    pthread_key_delete(key);
    return 0;
}
开发者ID:kobemiller,项目名称:mycode,代码行数:16,代码来源:4_pthread_key.c


示例16: 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
}
开发者ID:kennyb,项目名称:php-broken,代码行数:48,代码来源:TSRM.c


示例17: do_test

int
do_test (void)
{
  pthread_key_t keys[N];

  int i;
  for (i = 0; i < N; ++i)
    if (pthread_key_create (&keys[i], fcts[i]) != 0)
      {
	write (2, "key_create failed\n", 18);
	_exit (1);
      }

  pthread_t th;
  if (pthread_create (&th, NULL, tf, &keys[1]) != 0)
    {
      write (2, "create failed\n", 14);
      _exit (1);
    }

  if (pthread_join (th, NULL) != 0)
    {
      write (2, "join failed\n", 12);
      _exit (1);
    }

  if (cnt0 != 0)
    {
      write (2, "cnt0 != 0\n", 10);
      _exit (1);
    }

  if (cnt1 != 1)
    {
      write (2, "cnt1 != 1\n", 10);
      _exit (1);
    }

  for (i = 0; i < N; ++i)
    if (pthread_key_delete (keys[i]) != 0)
      {
	write (2, "key_delete failed\n", 18);
	_exit (1);
      }

  return 0;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:47,代码来源:tst-key2.c


示例18: di_rwlock_destroy

int di_rwlock_destroy(di_rwlock_t * self) {
    int retval;
    if (dirw == NULL) return EINVAL;

    retval = pthread_mutex_destroy(&self->writers_mutex);
    if (retval != 0) return retval;
    retval = pthread_rwlock_destroy(&self->rwlock1);
    if (retval != 0) return retval;
    retval = pthread_rwlock_destroy(&self->rwlock2);
    if (retval != 0) return retval;
    retval = pthread_key_delete(self->key);
    if (retval != 0) return retval;

    self->instance1 = NULL;
    self->instance2 = NULL;
    return 0;
}
开发者ID:bowlofstew,项目名称:ConcurrencyFreaks,代码行数:17,代码来源:di_rwlock.c


示例19: main

int main(void)
{
        int tid1,tid2;
        int cycle = 100;
        pthread_key_create(&key,NULL);
        
        while(cycle--)
        {
          pthread_create(&tid1,NULL,child1,NULL);
          pthread_create(&tid2,NULL,child2,NULL);
        }
        sleep(10);
        pthread_key_delete(key);

        printf("main thread exit\n");
        return 0;
}
开发者ID:clairewu,项目名称:Test-programs,代码行数:17,代码来源:jump_thread.c


示例20: close_logger

/* 关闭log文件 */
int
close_logger(int thread_num)
{
    int i, ret;
    /* 关闭log文件 */
    for (i = 0; i < thread_num; i++)
    {
        if (log_file[i]) {
            ret = fclose(log_file[i]);
            log_file[i] = NULL;
        }
    }

    /* 删除log id变量 */
    pthread_key_delete(log_id);
    return ret;
}
开发者ID:Forgrad,项目名称:filecached,代码行数:18,代码来源:log.c



注:本文中的pthread_key_delete函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pthread_mach_thread_np函数代码示例发布时间:2022-05-30
下一篇:
C++ pthread_key_create函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap