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

C++ pthread_condattr_destroy函数代码示例

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

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



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

示例1: create_cond

static int
create_cond(os_handler_t  *handler,
	    os_hnd_cond_t **new_cond)
{
    os_hnd_cond_t      *cond;
    pthread_condattr_t attr;
    int                rv;

    rv = pthread_condattr_init(&attr);
    if (rv)
	return rv;

    rv = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
    if (rv) {
	pthread_condattr_destroy(&attr);
	return rv;
    }

    cond = malloc(sizeof(*cond));
    if (!cond) {
	pthread_condattr_destroy(&attr);
	return ENOMEM;
    }

    rv = pthread_cond_init(&cond->cond, &attr);
    pthread_condattr_destroy(&attr);
    if (rv) {
	free(cond);
	return rv;
    }

    *new_cond = cond;
    return 0;
}
开发者ID:sharkconi,项目名称:openipmi,代码行数:34,代码来源:posix_thread_os_hnd.c


示例2: uv_cond_init

int uv_cond_init(uv_cond_t* cond) {
  pthread_condattr_t attr;
  int err;

  err = pthread_condattr_init(&attr);
  if (err)
    return -err;

#if !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
  err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
  if (err)
    goto error2;
#endif

  err = pthread_cond_init(cond, &attr);
  if (err)
    goto error2;

  err = pthread_condattr_destroy(&attr);
  if (err)
    goto error;

  return 0;

error:
  pthread_cond_destroy(cond);
error2:
  pthread_condattr_destroy(&attr);
  return -err;
}
开发者ID:sjw7453584,项目名称:Server,代码行数:30,代码来源:thread.c


示例3: start_sync_engine

/*
 * Main entry point to the sync engine
 */
void start_sync_engine(sqlite3 *db) {	
    pthread_attr_t  attr;
    pthread_t       p_thread_id;
    int             return_val;
    int thread_error;
	database = db;
	
#ifndef __SYMBIAN32__	
	// Initialize thread
    return_val = pthread_attr_init(&attr);
	pthread_condattr_init(&sync_details);
	pthread_cond_init(&sync_cond, &sync_details);
	pthread_condattr_destroy(&sync_details);
    assert(!return_val);
    return_val = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    assert(!return_val);
	  
    thread_error = pthread_create(&p_thread_id, &attr, &sync_engine_main_routine, NULL);
	
    return_val = pthread_attr_destroy(&attr);
    assert(!return_val);
    if (thread_error != 0) {
		  //TODO: Report error
    }
#else
    //[AA] posix thread is not required under the Symbian because we are using native Symbian threads
	pthread_condattr_init(&sync_details);
	pthread_cond_init(&sync_cond, &sync_details);
	pthread_condattr_destroy(&sync_details);
    
#endif	  
}
开发者ID:bijukrishna,项目名称:rhodes,代码行数:35,代码来源:SyncEngine.c


示例4: uv_cond_init

int uv_cond_init(uv_cond_t* cond) {
  pthread_condattr_t attr;

  if (pthread_condattr_init(&attr))
    return -1;

#if !defined(ANDROID)
  if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
    goto error2;
#endif

  if (pthread_cond_init(cond, &attr))
    goto error2;

  if (pthread_condattr_destroy(&attr))
    goto error;

  return 0;

error:
  pthread_cond_destroy(cond);
error2:
  pthread_condattr_destroy(&attr);
  return -1;
}
开发者ID:niceaji,项目名称:libuv,代码行数:25,代码来源:thread.c


示例5: Condition_Init

COND_HANDLE Condition_Init(void)
{
    // If we don't know our time basis, find it.
    if (time_basis == -1)
    {
        pthread_condattr_t cattr;
        pthread_condattr_init(&cattr);
        pthread_condattr_getclock(&cattr, &time_basis);
        pthread_condattr_destroy(&cattr);
    }

    // Codes_SRS_CONDITION_18_002: [ Condition_Init shall create and return a CONDITION_HANDLE ]
    pthread_cond_t * cond = (pthread_cond_t*)malloc(sizeof(pthread_cond_t));
    if (cond != NULL)
    {
        // set our time basis when configuring the condition
        pthread_condattr_t cattr;
        pthread_condattr_init(&cattr);
        pthread_condattr_setclock(&cattr, time_basis);
        pthread_cond_init(cond, &cattr);
        pthread_condattr_destroy(&cattr);
    }
    // Codes_SRS_CONDITION_18_008: [ Condition_Init shall return NULL if it fails to allocate the CONDITION_HANDLE ]
    return cond;
}
开发者ID:aog2000a,项目名称:azure-c-shared-utility,代码行数:25,代码来源:condition_pthreads.c


示例6: uv_cond_init

int uv_cond_init(uv_cond_t* cond) {
  pthread_condattr_t attr;
  int err;

  err = pthread_condattr_init(&attr);
  if (err)
    return UV__ERR(err);

#if !(defined(__ANDROID_API__) && __ANDROID_API__ < 21)
  err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
  if (err)
    goto error2;
#endif

  err = pthread_cond_init(cond, &attr);
  if (err)
    goto error2;

  err = pthread_condattr_destroy(&attr);
  if (err)
    goto error;

  return 0;

error:
  pthread_cond_destroy(cond);
error2:
  pthread_condattr_destroy(&attr);
  return UV__ERR(err);
}
开发者ID:AustinShalit,项目名称:allwpilib,代码行数:30,代码来源:thread.cpp


示例7: uv_cond_init

int uv_cond_init(uv_cond_t* cond) {
  pthread_condattr_t attr;

  if (pthread_condattr_init(&attr))
    return -1;
#ifndef __ANDROID__
  if (pthread_condattr_setclock(&attr, CLOCK_MONOTONIC))
#else
  if (pthread_condattr_setpshared(&attr, CLOCK_MONOTONIC))
#endif
    goto error2;

  if (pthread_cond_init(cond, &attr))
    goto error2;

  if (pthread_condattr_destroy(&attr))
    goto error;

  return 0;

error:
  pthread_cond_destroy(cond);
error2:
  pthread_condattr_destroy(&attr);
  return -1;
}
开发者ID:559210,项目名称:libpomelo,代码行数:26,代码来源:thread.c


示例8: qp_cond_create

qp_cond_t
qp_cond_create(qp_cond_t cond, bool shared)
{
    pthread_condattr_t    attr;
    
    if (NULL == cond) {
        cond = (qp_cond_t)qp_alloc(sizeof(struct qp_ipc_cond_s));
        
        if (NULL == cond) {
            return NULL;
        }
        
        memset(cond, 0, sizeof(struct qp_ipc_cond_s));
        qp_cond_set_alloced(cond);
        
    } else {
        memset(cond, 0, sizeof(struct qp_ipc_cond_s));
    }
    
    if (QP_SUCCESS != pthread_condattr_init(&attr)) {
        qp_cond_is_alloced(cond) ? qp_free(cond) : 1;
        return NULL;
    }
    
    if (NULL == qp_lock_init(&cond->cond_lock, shared, false)) {
        qp_cond_is_alloced(cond) ? qp_free(cond) : 1;
        return NULL;
    }
    
#ifdef _POSIX_THREAD_PROCESS_SHARED
    if (shared) {
        
        if (QP_SUCCESS != pthread_condattr_setpshared(&attr,
            PTHREAD_PROCESS_SHARED))
        {
            pthread_condattr_destroy(&attr);
            qp_lock_destroy(&cond->cond_lock);
            qp_cond_is_alloced(cond) ? qp_free(cond) : 1;
            return NULL;
        }
        
        qp_cond_set_shared(cond);
    }
#endif
    
    if (QP_SUCCESS != pthread_cond_init(&(cond->cond), &attr)) {
        pthread_condattr_destroy(&attr);
        qp_lock_destroy(&cond->cond_lock);
        qp_cond_is_alloced(cond) ? qp_free(cond) : 1;
        return NULL;
    }
    
    qp_cond_set_inited(cond);
    return cond;
}
开发者ID:2sui,项目名称:QPHi,代码行数:55,代码来源:qp_ipc_core.c


示例9: my_rw_init

int my_rw_init(my_rw_lock_t *rwp)
{
  pthread_condattr_t	cond_attr;

#ifdef _WIN32
  /*
    Once initialization is used here rather than in my_init(), in order to
    - avoid  my_init() pitfalls- (undefined order in which initialization should
    run)
    - be potentially useful C++ (static constructors) 
    - just to simplify  the API. 
    Also, the overhead is of my_pthread_once is very small.
  */
  static my_pthread_once_t once_control= MY_PTHREAD_ONCE_INIT;
  my_pthread_once(&once_control, check_srwlock_availability);

  if (have_srwlock)
    return srw_init(rwp);
#endif

  pthread_mutex_init( &rwp->lock, MY_MUTEX_INIT_FAST);
  pthread_condattr_init( &cond_attr );
  pthread_cond_init( &rwp->readers, &cond_attr );
  pthread_cond_init( &rwp->writers, &cond_attr );
  pthread_condattr_destroy(&cond_attr);

  rwp->state	= 0;
  rwp->waiters	= 0;
#ifdef SAFE_MUTEX
  rwp->write_thread   = 0;
#endif

  return(0);
}
开发者ID:Springlin,项目名称:david-mysql-tools,代码行数:34,代码来源:thr_rwlock.c


示例10: defined

void CPosixThreadImpl::start(IRhoRunnable *pRunnable, IRhoRunnable::EPriority ePriority)
{
#if defined(OS_ANDROID)
    // Android has no pthread_condattr_xxx API
    pthread_cond_init(&m_condSync, NULL);
#else
    pthread_condattr_t sync_details;
    pthread_condattr_init(&sync_details);
    pthread_cond_init(&m_condSync, &sync_details);
    pthread_condattr_destroy(&sync_details);
#endif

    pthread_attr_t  attr;
    int return_val = pthread_attr_init(&attr);
    return_val = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
    RHO_ASSERT(!return_val);

    if ( ePriority != IRhoRunnable::epNormal)
    {
        sched_param param;
        return_val = pthread_attr_getschedparam (&attr, &param);
        param.sched_priority = ePriority == IRhoRunnable::epLow ? 20 : 100; //TODO: sched_priority
        return_val = pthread_attr_setschedparam (&attr, &param);
    }

    int thread_error = pthread_create(&m_thread, &attr, &runProc, pRunnable);
    return_val = pthread_attr_destroy(&attr);
    RHO_ASSERT(!return_val);
    RHO_ASSERT(thread_error==0);
}
开发者ID:MacBoyPro,项目名称:rhodes,代码行数:30,代码来源:PosixThreadImpl.cpp


示例11: OSA_queCreate

int OSA_queCreate(OSA_QueHndl *hndl, Uint32 maxLen)
{
  pthread_mutexattr_t mutex_attr;
  pthread_condattr_t cond_attr;
  int status=OSA_SOK;

  hndl->curRd = hndl->curWr = 0;
  hndl->count = 0;
  hndl->len   = maxLen;
  hndl->queue = OSA_memAlloc(sizeof(Int32)*hndl->len);
  
  if(hndl->queue==NULL) {
    OSA_ERROR("OSA_queCreate() = %d \r\n", status);
    return OSA_EFAIL;
  }
 
  status |= pthread_mutexattr_init(&mutex_attr);
  status |= pthread_condattr_init(&cond_attr);  
  
  status |= pthread_mutex_init(&hndl->lock, &mutex_attr);
  status |= pthread_cond_init(&hndl->condRd, &cond_attr);    
  status |= pthread_cond_init(&hndl->condWr, &cond_attr);  

  if(status!=OSA_SOK)
    OSA_ERROR("OSA_queCreate() = %d \r\n", status);
    
  pthread_condattr_destroy(&cond_attr);
  pthread_mutexattr_destroy(&mutex_attr);
    
  return status;
}
开发者ID:119,项目名称:ipnc,代码行数:31,代码来源:osa_que.c


示例12: defined

    int ConditionVariable::Construct()
    {
#if defined(CIO_IOS)
        pthread_cond_init(&cond_, nullptr);
#elif defined(CIO_ANDROID)
        int result = 0;
        pthread_condattr_t cond_attr;
        result = pthread_condattr_init(&cond_attr);
        if (result != 0) {
            return -1;
        }
        result = pthread_condattr_setclock(&cond_attr, CLOCK_MONOTONIC);
        if (result != 0) {
            return -1;
        }
        result = pthread_cond_init(&cond_, &cond_attr);
        if (result != 0) {
            return -1;
        }
        result = pthread_condattr_destroy(&cond_attr);
        if (result != 0) {
            return -1;
        }
#endif
        
        return 0;
    }
开发者ID:chenjianjun571,项目名称:cioforandroid,代码行数:27,代码来源:ConditionVariable.cpp


示例13: pthread_condattr_init

IceUtil::Cond::Cond()
{
    pthread_condattr_t attr;

    int rc = pthread_condattr_init(&attr);
    if(rc != 0)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, rc);
    }

#if !defined(__hpux) && !defined(__APPLE__)
    rc = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); 
    if(rc != 0)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, rc);
    }
#endif

    rc = pthread_cond_init(&_cond, &attr);
    if(rc != 0)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, rc);
    }

    rc = pthread_condattr_destroy(&attr);
    if(rc != 0)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, rc);
    }
}
开发者ID:2008hatake,项目名称:zeroc-ice,代码行数:30,代码来源:Cond.cpp


示例14: myFailedInit

AREXPORT ArCondition::ArCondition() :
  myFailedInit(false),
  myCond(),
  myMutex()
{
  myMutex.setLogName("ArCondition::myMutex");
  pthread_condattr_t attr;

  pthread_condattr_init(&attr);
  if (pthread_cond_init(&myCond, &attr) != 0)
  {
    ArLog::log(ArLog::Terse, "ArCondition::ArCondition: Unknown error trying to create the condition.");
    myFailedInit=true;
  }

  pthread_condattr_destroy(&attr);

  ourStrMap[STATUS_FAILED]="General failure";
  ourStrMap[STATUS_FAILED_DESTROY]=
  "Another thread is waiting on this condition so it can not be destroyed";
  ourStrMap[STATUS_FAILED_INIT] =
  "Failed to initialize thread. Requested action is imposesible";
  ourStrMap[STATUS_MUTEX_FAILED_INIT]="The underlying mutex failed to init";
  ourStrMap[STATUS_MUTEX_FAILED]="The underlying mutex failed in some fashion";
}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:25,代码来源:ArCondition_LIN.cpp


示例15: NdbCondition_Init

int
NdbCondition_Init(struct NdbCondition* ndb_cond)
{
  int result;

  assert(init); /* Make sure library has been initialized */

#if defined HAVE_CLOCK_GETTIME && defined HAVE_PTHREAD_CONDATTR_SETCLOCK && \
    defined CLOCK_MONOTONIC
  if (clock_id == CLOCK_MONOTONIC)
  {
    pthread_condattr_t attr;
    pthread_condattr_init(&attr);
    pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
    result = pthread_cond_init(&ndb_cond->cond, &attr);
    pthread_condattr_destroy(&attr);
  }
  else
  {
    result = pthread_cond_init(&ndb_cond->cond, NULL);
  }
#else
  result = native_cond_init(&ndb_cond->cond);
#endif
  assert(result==0);
  return result;
}
开发者ID:carrotli,项目名称:ansql,代码行数:27,代码来源:NdbCondition.c


示例16: tc_pthread_pthread_cond_init_destroy

/**
* @fn                   :tc_pthread_pthread_cond_init_destroy
* @brief                :pthread_cond_init initialises the condition variable referenced by cond with attributes referenced by attr
*                        pthread_cond_destroy destroy the given condition variable specified by cond
* @Scenario             :pthread_cond_init initialises the condition variable referenced by cond with attributes referenced by attr
*                        pthread_cond_destroy destroy the given condition variable specified by cond
* API's covered         :pthread_cond_init, pthread_cond_destroy
* Preconditions         :none
* Postconditions        :none
* @return               :void
*/
static void tc_pthread_pthread_cond_init_destroy(void)
{
	int ret_chk;
	pthread_condattr_t attr;
	pthread_cond_t cond_nullparam;
	pthread_cond_t cond_attrparam;

	ret_chk = pthread_condattr_init(&attr);
	TC_ASSERT_EQ("pthread_condattr_init", ret_chk, OK);

	/* parameters of pthread_cond_init are of opaque data type hence parameter check not possible */
	ret_chk = pthread_cond_init(&cond_nullparam, NULL);
	TC_ASSERT_EQ("pthread_cond_init", ret_chk, OK);

	ret_chk = pthread_cond_init(&cond_attrparam, &attr);
	TC_ASSERT_EQ("pthread_cond_init", ret_chk, OK);

	ret_chk = pthread_cond_destroy(&cond_nullparam);
	TC_ASSERT_EQ("pthread_cond_destroy", ret_chk, OK);

	ret_chk = pthread_cond_destroy(&cond_attrparam);
	TC_ASSERT_EQ("pthread_cond_destroy", ret_chk, OK);

	ret_chk = pthread_condattr_destroy(&attr);
	TC_ASSERT_EQ("pthread_condattr_destroy", ret_chk, OK);

	TC_SUCCESS_RESULT();
}
开发者ID:carhero,项目名称:TizenRT,代码行数:39,代码来源:tc_pthread.c


示例17: OSA_msgqCreate

int OSA_msgqCreate(OSA_MsgqHndl *hndl)
{
  pthread_mutexattr_t mutex_attr;
  pthread_condattr_t cond_attr;
  int status=OSA_SOK;
 
  status |= pthread_mutexattr_init(&mutex_attr);
  status |= pthread_condattr_init(&cond_attr);  
  
  status |= pthread_mutex_init(&hndl->lock, &mutex_attr);
  status |= pthread_cond_init(&hndl->condRd, &cond_attr);    
  status |= pthread_cond_init(&hndl->condWr, &cond_attr);  

  hndl->curRd = hndl->curWr = 0;
  hndl->count = 0;
  hndl->len   = OSA_MSGQ_LEN_MAX;

  if(status!=OSA_SOK)
    OSA_ERROR("OSA_msgqCreate() = %d \r\n", status);
    
  pthread_condattr_destroy(&cond_attr);
  pthread_mutexattr_destroy(&mutex_attr);
    
  return status;
}
开发者ID:JammyWei,项目名称:dm8168,代码行数:25,代码来源:osa_msgq.c


示例18: _dbus_pthread_condvar_new

static DBusCondVar *
_dbus_pthread_condvar_new (void)
{
  DBusCondVarPThread *pcond;
  pthread_condattr_t attr;
  int result;
  
  pcond = dbus_new (DBusCondVarPThread, 1);
  if (pcond == NULL)
    return NULL;

  pthread_condattr_init (&attr);
#ifdef HAVE_MONOTONIC_CLOCK
  if (have_monotonic_clock)
    pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
#endif

  result = pthread_cond_init (&pcond->cond, &attr);
  pthread_condattr_destroy (&attr);

  if (result == EAGAIN || result == ENOMEM)
    {
      dbus_free (pcond);
      return NULL;
    }
  else
    {
      PTHREAD_CHECK ("pthread_cond_init", result);
    }
  
  return DBUS_COND_VAR (pcond);
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:32,代码来源:dbus-sysdeps-pthread.c


示例19: pthread_condattr_init

Cond::Cond()
{
    pthread_condattr_t attr;
    int rt = pthread_condattr_init(&attr);
#ifdef _NO_EXCEPTION
    assert( 0 == rt );
#else
    if( 0 != rt )
    {
        throw ThreadSyscallException(__FILE__, __LINE__, rt);
    }
#endif
    
    rt =  pthread_cond_init(&_cond, &attr);
#ifdef _NO_EXCEPTION
    assert( 0 == rt );
#else
    if( 0 != rt )
    {
        throw ThreadSyscallException(__FILE__, __LINE__, rt);
    }
#endif

    rt = pthread_condattr_destroy(&attr);
#ifdef _NO_EXCEPTION
    assert( 0 == rt );
#else
    if( 0 != rt )
    {
        throw ThreadSyscallException(__FILE__, __LINE__, rt);
    }
#endif
}
开发者ID:CCoder123,项目名称:pproj,代码行数:33,代码来源:Cond.cpp


示例20: pthread_condattr_init

Threading::Cond::Cond(void) 
{
    pthread_condattr_t condattr;

    int returnVal = pthread_condattr_init(&condattr);
    if (0 != returnVal)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, returnVal);
    }

#if ! defined(__hpux) && ! defined(__APPLE__)
    returnVal = pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC); 
    if (0 != returnVal)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, returnVal);
    }
#endif

    returnVal = pthread_cond_init(&m_cond, &condattr);
    if (0 != returnVal)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, returnVal);
    }

    returnVal = pthread_condattr_destroy(&condattr);
    if (0 != returnVal)
    {
        throw ThreadSyscallException(__FILE__, __LINE__, returnVal);
    }
}
开发者ID:happyluo,项目名称:Threading,代码行数:30,代码来源:Cond.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pthread_condattr_init函数代码示例发布时间:2022-05-30
下一篇:
C++ pthread_cond_wait函数代码示例发布时间: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