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


C++ pthread_condattr_destroy函数代码示例

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


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


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