当前位置: 首页>>代码示例>>C++>>正文


C++ pthread_mutexattr_destroy函数代码示例

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


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

示例1: ags_lv2_option_manager_finalize

void
ags_lv2_option_manager_finalize(GObject *gobject)
{
  AgsLv2OptionManager *lv2_option_manager;

  lv2_option_manager = AGS_LV2_OPTION_MANAGER(gobject);
  
  g_hash_table_destroy(lv2_option_manager->ressource);

  if(lv2_option_manager == ags_lv2_option_manager){
    ags_lv2_option_manager = NULL;
  }

  pthread_mutex_destroy(lv2_option_manager->obj_mutex);
  free(lv2_option_manager->obj_mutex);

  pthread_mutexattr_destroy(lv2_option_manager->obj_mutexattr);
  free(lv2_option_manager->obj_mutexattr);

  /* call parent */
  G_OBJECT_CLASS(ags_lv2_option_manager_parent_class)->finalize(gobject);  
}
开发者ID:gsequencer,项目名称:gsequencer,代码行数:22,代码来源:ags_lv2_option_manager.c

示例2: slog_init

/*
 * Initialize slog library. Function parses config file and reads log 
 * level and save to file flag from config. First argument is file name 
 * where log will be saved and second argument conf is config file path 
 * to be parsedand third argument lvl is log level for this message.
 */
void slog_init(const char* fname, const char* conf, int lvl, int flvl, int t_safe)
{
    int status = 0;

    /* Set up default values */
    slg.level = lvl;
    slg.file_level = flvl;
    slg.to_file = 0;
    slg.pretty = 0;
    slg.filestamp = 1;
    slg.td_safe = t_safe;

    /* Init mutex sync */
    if (t_safe)
    {
        /* Init mutex attribute */
        pthread_mutexattr_t m_attr;
        if (pthread_mutexattr_init(&m_attr) ||
            pthread_mutexattr_settype(&m_attr, PTHREAD_MUTEX_RECURSIVE) ||
            pthread_mutex_init(&slog_mutex, &m_attr) ||
            pthread_mutexattr_destroy(&m_attr))
        {
            printf("<%s:%d> %s: [ERROR] Can not initialize mutex: %d\n", 
                __FILE__, __LINE__, __FUNCTION__, errno);
            slg.td_safe = 0;
        }
    }

    /* Parse config file */
    if (conf != NULL) 
    {
        slg.fname = fname;
        status = parse_config(conf);
    }

    /* Handle config parser status */
    if (!status) slog(0, SLOG_INFO, "Initializing logger values without config");
    else slog(0, SLOG_INFO, "Loading logger config from: %s", conf);
}
开发者ID:sib8th,项目名称:php_tracer,代码行数:45,代码来源:slog.c

示例3: throw

//critical_section_t
critical_section_t::critical_section_t(bool recursive_flag) throw()
{
#ifdef LINUX

        pthread_mutexattr_t mtx_attr;
        pthread_mutexattr_init(&mtx_attr);
        if(recursive_flag) pthread_mutexattr_settype(&mtx_attr, PTHREAD_MUTEX_RECURSIVE);
        pthread_mutex_init(&_mtx, &mtx_attr);
        pthread_mutexattr_destroy(&mtx_attr);
#elif defined(WIN32)

	if(recursive_flag)
	{
		InitializeCriticalSection(&_cs);
		_sem = NULL;
	}
	else //non-recursive
	{
		_sem = ::CreateSemaphore(NULL,1,1,NULL);
	}
#endif //LINUX
}
开发者ID:ferstar,项目名称:fy2009,代码行数:23,代码来源:fy_base.cpp

示例4: PMS_CreateCriticalSection

/*! \brief Create and initialize a critical section
 *
 * UNIX/Linux
 *
 * \return Pointer to critical section created and initialized (casted to \c void *).
*/
void * PMS_CreateCriticalSection(void)
{
  pthread_mutex_t * ptCS;          /* Mutex for critical section */
  pthread_mutexattr_t mutexattr;   /* Mutex attribute variable */

  ptCS = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
  if(!ptCS) {
    PMS_SHOW_ERROR("Failed to allocation critical section structure\n");
    return NULL;
  }
#ifndef PMS_OIL_MERGE_DISABLE_MEM
  memVal+=sizeof(pthread_mutex_t);
#endif

  /* Initialize the attributes set */
  pthread_mutexattr_init(&mutexattr);

#ifdef MACOSX
  /* Set the mutex as a normal mutex */
  pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_NORMAL);
#else
#ifdef __NetBSD__
  /* Set the mutex as a normal mutex */
  pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_NORMAL);
#else
  /* Set the mutex as a fast mutex */
  pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ADAPTIVE_NP);
#endif
#endif

  /* create the mutex with the attributes set */
  pthread_mutex_init(ptCS, &mutexattr);

  /* After initializing the mutex, the attribute can be destroyed */
  pthread_mutexattr_destroy(&mutexattr);

  return (void*)ptCS;
}
开发者ID:jo244305wipro,项目名称:RiCRiPInt,代码行数:44,代码来源:pms_platform.c

示例5: main

int main(void)
{
	int ret;
	pthread_t tid[2];
	pthread_attr_t attr;
	pthread_mutexattr_t mutexattr;

	pthread_attr_init(&attr);
	pthread_mutexattr_init(&mutexattr);

	pthread_attr_setdetachstate(&attr, 
		PTHREAD_CREATE_DETACHED);
	pthread_mutexattr_settype(&mutexattr,
		PTHREAD_MUTEX_RECURSIVE_NP);
	
	pthread_mutex_init(&lock, &mutexattr);
	pthread_mutexattr_destroy(&mutexattr);



	ret = pthread_create(&tid[0], &attr, 
		test0, NULL);
	if (ret) {
		fprintf(stderr, "create:%s\n", strerror(ret));
		exit(1);
	}

	ret = pthread_create(&tid[0], &attr, 
		test1, NULL);
	if (ret) {
		fprintf(stderr, "create:%s\n", strerror(ret));
		exit(1);
	}	

	pthread_attr_destroy(&attr);

	pthread_exit(NULL);
}
开发者ID:guolilong2012,项目名称:study,代码行数:38,代码来源:recursive.c

示例6: initCrashSimulationThread

int initCrashSimulationThread(rtSimulationThread_t *p_thread, inputThread_t *p_inputThread)
{
	int ret;
	pthread_mutexattr_t attr;
	
	ret = initRTMutexAttr(&attr);
	if(ret != 0) {
		PRINT_ERR("Failed to init rt mutex attributes (%d).\n", ret);
		return ret;
	}
	
	ret = pthread_mutex_init(&p_thread->simulationMutex, &attr);
	if(ret != 0) {
		PRINT_ERR("Failed to init mutex (%d).\n", ret);
		return ret;
	}
	
	ret = pthread_barrier_init(&p_thread->startBarrier, NULL, 2);
	if(ret != 0) {
		PRINT_ERR("Failed to init barrier (%d).\n", ret);
		return ret;
	}
	
	ret = initSimulation(&p_thread->simulation, DEF_DISTANCE);
	if(ret != 0) {
		PRINT_ERR("Failed to init simulation (%d).\n", ret);
		return ret;
	}
	p_thread->simulate = 0;
	p_thread->keepRunning = 0;
	p_thread->running = 0;
	p_thread->exitCode = 0;
	p_thread->inputThread = p_inputThread;
	
	pthread_mutexattr_destroy(&attr);
	
	return 0;
}
开发者ID:RealzeitsystemeSS14,项目名称:SpeechRecognition,代码行数:38,代码来源:SimulationThread.c

示例7: do_test

static int
do_test (void)
{
  pthread_mutex_t m;

  int e = pthread_mutex_init (&m, ATTR);
  if (ATTR != NULL && e == ENOTSUP)
    {
      puts ("cannot support selected type of mutexes");
      e = pthread_mutex_init (&m, NULL);
    }
  if (e != 0)
    {
      puts ("mutex_init failed");
      return 1;
    }

  if (ATTR != NULL && pthread_mutexattr_destroy (ATTR) != 0)
    {
      puts ("mutexattr_destroy failed");
      return 1;
    }

  if (pthread_mutex_lock (&m) != 0)
    {
      puts ("1st mutex_lock failed");
      return 1;
    }

  /* Set an alarm for 1 second.  The wrapper will expect this.  */
  alarm (1);

  /* This call should never return.  */
  pthread_mutex_lock (&m);

  puts ("2nd mutex_lock returned");
  return 1;
}
开发者ID:Xilinx,项目名称:eglibc,代码行数:38,代码来源:tst-mutex6.c

示例8: main

int main()
{
	pthread_mutexattr_t mta;
	int rc;

	/* Initialize a mutex attributes object */
	if ((rc=pthread_mutexattr_init(&mta)) != 0)
	{
		fprintf(stderr,"Cannot initialize mutex attributes object\n");
		return PTS_UNRESOLVED;
	}

	/* Destroy the mutex attributes object */
	if (pthread_mutexattr_destroy(&mta) != 0)
	{
		fprintf(stderr,"Error at pthread_mutexattr_destroy(), rc=%d\n", rc);
		printf("Test FAILED\n");
		return PTS_FAIL;
	}

	printf("Test PASSED\n");
	return PTS_PASS;
}
开发者ID:shubmit,项目名称:shub-ltp,代码行数:23,代码来源:1-1.c

示例9: usbi_mutex_init_recursive

int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr)
{
	int err;
	pthread_mutexattr_t stack_attr;
	if (!attr) {
		attr = &stack_attr;
		err = pthread_mutexattr_init(&stack_attr);
		if (err != 0)
			return err;
	}

	err = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE);
	if (err != 0)
		goto finish;

	err = pthread_mutex_init(mutex, attr);

finish:
	if (attr == &stack_attr)
		pthread_mutexattr_destroy(&stack_attr);

	return err;
}
开发者ID:1065672644894730302,项目名称:Chromium,代码行数:23,代码来源:threads_posix.c

示例10: DeleteCriticalSection

IMutexLock::IMutexLock()
{
#ifdef  WIN32
  if (InitializeCriticalSectionAndSpinCount(&_M_mutex, 2000) != TRUE) {
    DeleteCriticalSection(&_M_mutex);
    std::cerr << "init critical section failed !" << std::endl;
  }
#elif defined(HAVE_PTHREAD)
  int       _ret_code = 0;
  if ((_ret_code = pthread_mutexattr_init(&_M_mutexattr)) != 0)
    std::cerr << "mutex attribute init failed !" << std::endl;
  if (_ret_code == 0)
    _ret_code = pthread_mutexattr_settype(&_M_mutexattr, PTHREAD_MUTEX_ERRORCHECK);
  if (_ret_code == 0)
    if ((_ret_code = pthread_mutex_init(&_M_mutex, &_M_mutexattr)) != 0)
      err_msg("pthread_mutex_init failed");

  if (_ret_code != 0) {
    (void)pthread_mutex_destroy(&_M_mutex);
    (void)pthread_mutexattr_destroy(&_M_mutexattr);
  }
#endif  // end of WIN32
}
开发者ID:xubodong1994,项目名称:test,代码行数:23,代码来源:ithread.cpp

示例11: defined

zMutex::zMutex(void) {
  _lockedCount = 0;
  _isDestroying = false;

#if defined(_WIN32)
  _cs = new CRITICAL_SECTION;
  InitializeMutexAndSpinCount((LPCRITICAL_SECTION)_cs, 500);
#else
  pthread_mutexattr_t mutexAttr;

  int res = pthread_mutexattr_init(&mutexAttr);
  CHECK_FATAL(res, "pthread_mutexattr_init");

  res = pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_RECURSIVE);
  CHECK_FATAL(res, "pthread_mutexattr_settype PTHREAD_MUTEX_RECURSIVE");

  res = pthread_mutex_init(&_mutex, &mutexAttr);
  CHECK_FATAL(res, "pthread_mutex_init");

  res = pthread_mutexattr_destroy(&mutexAttr);
  CHECK_FATAL(res, "pthread_mutexattr_destroy");
#endif
}
开发者ID:zanfire,项目名称:zanssh,代码行数:23,代码来源:zMutex.cpp

示例12: pthread_mutex_t

/**
 * Contruct our Mutex
 */
dashee::Threads::LockMutex::LockMutex()
{
    this->mutex = new pthread_mutex_t();
    this->attr = new pthread_mutexattr_t();
    
    if (pthread_mutexattr_init(this->attr) != 0)
	throw ExceptionLock("Thread attribute init failed");

    if (pthread_mutexattr_settype(this->attr, PTHREAD_MUTEX_ERRORCHECK) != 0)
	throw ExceptionLock("Thread attribute set failed");
    
    // Make sure that initilization comes out as good, otherwise we should
    // absolutly die die die
    int ec = pthread_mutex_init(this->mutex, this->attr);
    if (ec != 0)
	throw ExceptionLock(
		"Error Initilizing LockMutex, ec='" + 
		dashee::itostr(ec) + "'. This should not happen!"
	    );

    pthread_mutexattr_destroy(this->attr);
    this->attr = NULL;
}
开发者ID:Sumeet002,项目名称:dashee,代码行数:26,代码来源:Mutex.cpp

示例13: bmalloc

static void *scene_create(obs_data_t settings, struct obs_source *source)
{
	pthread_mutexattr_t attr;
	struct obs_scene *scene = bmalloc(sizeof(struct obs_scene));
	scene->source     = source;
	scene->first_item = NULL;

	if (pthread_mutexattr_init(&attr) != 0)
		goto fail;
	if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0)
		goto fail;
	if (pthread_mutex_init(&scene->mutex, &attr) != 0) {
		blog(LOG_ERROR, "scene_create: Couldn't initialize mutex");
		goto fail;
	}

	return scene;

fail:
	pthread_mutexattr_destroy(&attr);
	bfree(scene);
	return NULL;
}
开发者ID:Tyrrr,项目名称:obs-studio,代码行数:23,代码来源:obs-scene.c

示例14: poster

    poster(Blink * _blink, bool & ok)
      : state(WAIT), blink(_blink)
    {
      pthread_mutexattr_t attr;
      pthread_mutexattr_init(&attr);
      pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
      pthread_mutex_init(&mutex, &attr);
      pthread_mutexattr_destroy(&attr);
      switch(pthread_create(&thread_id, 0, run, this)){
      case EAGAIN:
	if(0 != blink->m_os)
	  (*blink->m_os) << "insufficient resources for thread.\n";
	ok = false;
	break;
      case EINVAL:
	if(0 != blink->m_os)
	  (*blink->m_os) << "BUG [invalid attr for pthread_create()]\n";
	ok = false;
	break;
      default:
	ok = true;
      }
    }
开发者ID:poftwaresatent,项目名称:cerebrate,代码行数:23,代码来源:Blink.cpp

示例15: pthread_mutex_destroy

/*---------------------------------------------------------------------------------*/
void engine::finalize(){
  if ( runMultiThread ) {
    pthread_mutex_destroy(&thread_lock);
    pthread_mutexattr_destroy(&mutex_attr);
    task_submission_finished=true;
    LOG_INFO(LOG_MULTI_THREAD,"before join\n");
    if ( thread_model  >=1){
      pthread_join(mbsend_tid,NULL);
      LOG_INFO(LOG_MULTI_THREAD," MBSend thread joined\n");
    }
    if ( thread_model  >=2){
      pthread_join(mbrecv_tid,NULL);
      LOG_INFO(LOG_MULTI_THREAD,"MBRecv thread joined\n");
    }
    pthread_join(thread_id,NULL);
    LOG_INFO(LOG_MULTI_THREAD,"Admin thread joined\n");
  }
  else
    doProcessLoop((void *)this);
  globalSync();
  if(cfg->getDLB())
    dlb.dumpDLB();
}
开发者ID:afshin-zafari,项目名称:DuctTeip,代码行数:24,代码来源:engine.cpp


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