本文整理汇总了C++中pthread_rwlock_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_rwlock_destroy函数的具体用法?C++ pthread_rwlock_destroy怎么用?C++ pthread_rwlock_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pthread_rwlock_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SrvTree2Free
static
VOID
SrvTree2Free(
PLWIO_SRV_TREE_2 pTree
)
{
LWIO_LOG_DEBUG("Freeing tree [object:0x%x][tid:%u]",
pTree,
pTree->ulTid);
// Cannot be in the parent since parent would have a reference.
LWIO_ASSERT(!SrvTree2IsInParent_inlock(pTree));
if (pTree->pMutex)
{
pthread_rwlock_destroy(&pTree->mutex);
pTree->pMutex = NULL;
}
if (pTree->pFileCollection)
{
LwRtlRBTreeFree(pTree->pFileCollection);
}
if (pTree->hFile)
{
IoCloseFile(pTree->hFile);
}
if (pTree->pShareInfo)
{
SrvShareReleaseInfo(pTree->pShareInfo);
}
if (pTree->resource.ulResourceId)
{
PSRV_RESOURCE pResource = NULL;
SrvElementsUnregisterResource(pTree->resource.ulResourceId,
&pResource);
pTree->resource.ulResourceId = 0;
}
// Release parent at the end
if (pTree->pSession)
{
SrvSession2Release(pTree->pSession);
}
SrvFreeMemory(pTree);
}
示例2: main
int main(void)
{
int cnt = 0;
int rc = 0;
pthread_t thread;
rc = pthread_rwlock_init(&rwlock, NULL);
if (rc != 0) {
printf
("Test FAILED: Error at pthread_rwlock_init(), returns %d\n",
rc);
return PTS_FAIL;
}
thread_state = 1;
printf("main: create thread\n");
if (pthread_create(&thread, NULL, fn_rd, NULL) != 0) {
printf("main: failed to create thread\n");
return PTS_UNRESOLVED;
}
/* If the shared data is not altered by child after 3 seconds,
we regard it as blocked */
/* We expect the thread not to block */
cnt = 0;
do {
sleep(1);
} while (thread_state != 3 && cnt++ < 3);
if (thread_state == 2) {
printf("Test FAILED: thread blocked on read lock\n");
exit(PTS_FAIL);
} else if (thread_state != 3) {
printf("main: Unexpected thread state\n");
exit(PTS_UNRESOLVED);
}
if (pthread_join(thread, NULL) != 0) {
printf("main: Error at pthread_join()\n");
exit(PTS_UNRESOLVED);
}
if (pthread_rwlock_destroy(&rwlock) != 0) {
printf("Error at pthread_rwlock_destroy()\n");
return PTS_UNRESOLVED;
}
printf("Test PASSED\n");
return PTS_PASS;
}
示例3: mas_threads_destroy
void
mas_threads_destroy( void )
{
CTRL_PREPARE;
pthread_attr_destroy( &ctrl.thglob.custom_attr );
pthread_attr_destroy( &ctrl.thglob.logger_attr );
pthread_cond_destroy( &ctrl.thglob.logger_wait_cond );
pthread_mutex_destroy( &ctrl.thglob.logger_wait_mutex );
pthread_attr_destroy( &ctrl.thglob.master_attr );
pthread_attr_destroy( &ctrl.thglob.ticker_attr );
pthread_attr_destroy( &ctrl.thglob.watcher_attr );
CPU_FREE( ctrl.thglob.master_set );
ctrl.thglob.master_set = NULL;
pthread_attr_destroy( &ctrl.thglob.listener_attr );
CPU_FREE( ctrl.thglob.listener_set );
ctrl.thglob.listener_set = NULL;
pthread_attr_destroy( &ctrl.thglob.transaction_attr );
CPU_FREE( ctrl.thglob.transaction_set );
ctrl.thglob.transaction_set = NULL;
pthread_rwlock_destroy( &ctrl.thglob.modules_list_rwlock );
pthread_rwlock_destroy( &ctrl.thglob.lcontrols_list_rwlock );
pthread_rwlock_destroy( &ctrl.thglob.control_rwlock );
pthread_mutex_destroy( &ctrl.thglob.mfp_mutex );
pthread_mutex_destroy( &ctrl.thglob.msg_mutex );
pthread_mutex_destroy( &ctrl.thglob.emsg_mutex );
pthread_mutex_destroy( &ctrl.thglob.cleanup_transactions_mutex );
pthread_mutex_destroy( &ctrl.thglob.malloc_mutex );
pthread_mutex_destroy( &ctrl.thglob.cnttr1_mutex );
pthread_mutex_destroy( &ctrl.thglob.cnttr2_mutex );
//pthread_mutex_destroy( &ctrl.thglob.log_mutex );
}
示例4: bthread_timer_del
void DownSpeed::Clear()
{
#ifdef CszTest
Csz::LI("[%s->%s->%d]",__FILE__,__func__,__LINE__);
#endif
auto code= bthread_timer_del(id);
if (code!= 0)
{
Csz::ErrMsg("[%s->%s->%d]->failed,calculate speed still running or einval,code=%d",__FILE__,__func__,__LINE__,code);
}
pthread_rwlock_destroy(&lock);
queue.clear();
return ;
}
示例5: sharddir_delete
void
sharddir_delete(struct sharddir **sharddp)
{
struct sharddir *shardd;
AN(sharddp);
shardd = *sharddp;
*sharddp = NULL;
CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC);
shardcfg_delete(shardd);
AZ(pthread_rwlock_destroy(&shardd->mtx));
FREE_OBJ(shardd);
}
示例6: NpfsFreeFCB
NTSTATUS
NpfsFreeFCB(
PNPFS_FCB pFCB
)
{
NTSTATUS ntStatus = 0;
pthread_rwlock_destroy(&pFCB->PipeListRWLock);
LwRtlUnicodeStringFree(&pFCB->PipeName);
NpfsFreeMemory(pFCB);
return(ntStatus);
}
示例7: thread_rwlock_cleanup
static apr_status_t thread_rwlock_cleanup(void *data)
{
apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data;
apr_status_t stat;
pthread_rwlock_unlock(rwlock->rwlock);
stat = pthread_rwlock_destroy(rwlock->rwlock);
#ifdef PTHREAD_SETS_ERRNO
if (stat) {
stat = errno;
}
#endif
return stat;
}
示例8: delete_list
void delete_list(c_list *list) {
if(list) {
c_node *tmp = list->head;
while(tmp) {
c_node *tmp2 = tmp;
tmp = tmp2->next;
delete_node(tmp2);
}
pthread_rwlock_destroy((list->lock));
free(list->lock);
free(list);
}
}
示例9: __attribute
/* clean up upon library unload */
void __attribute ((destructor)) memhack_exit (void)
{
u32 i;
#if USE_DEBUG_LOG
if (DBG_FILE_VAR) {
fflush(DBG_FILE_VAR);
fclose(DBG_FILE_VAR);
}
#endif
if (!active || !config)
return;
for (i = 0; config[i] != NULL; i++)
pthread_rwlock_destroy(&config[i]->lock);
}
示例10: CRYPTO_THREAD_lock_free
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
{
if (lock == NULL)
return;
# ifdef USE_RWLOCK
pthread_rwlock_destroy(lock);
# else
pthread_mutex_destroy(lock);
# endif
OPENSSL_free(lock);
return;
}
示例11: vdir_delete
void
vdir_delete(struct vdir **vdp)
{
struct vdir *vd;
TAKE_OBJ_NOTNULL(vd, vdp, VDIR_MAGIC);
AZ(vd->dir);
free(vd->backend);
free(vd->weight);
AZ(pthread_rwlock_destroy(&vd->mtx));
vbit_destroy(vd->healthy);
FREE_OBJ(vd);
}
示例12: lookupRefDestruct
static void
lookupRefDestruct(lookup_ref_t *pThis)
{
lookupStopReloader(pThis);
pthread_mutex_destroy(&pThis->reloader_mut);
pthread_cond_destroy(&pThis->run_reloader);
pthread_attr_destroy(&pThis->reloader_thd_attr);
pthread_rwlock_destroy(&pThis->rwlock);
lookupDestruct(pThis->self);
free(pThis->name);
free(pThis->filename);
free(pThis);
}
示例13: thread_list_free
void thread_list_free(struct thread_list_t *list)
{
struct thread_list_node_t *prev = NULL;
pthread_rwlock_destroy(&list->lock);
while (list->head)
{
prev = list->head;
list->head = list->head->next;
free(prev);
}
free(list);
}
示例14: rbt_free
/**
* Free resources used to hold information about the tree. This
* function does not free memory pointed to by the data pointer
* in a node - you have to free this memory by walking thru the
* tree or use the callback version of rbt_free for a specific
* tree type.
* @param rbt tree pointer
*/
void rbt_free(rbt_t *rbt, void (*callback)(void *))
{
struct rbt_node *stack[48], *n;
register uint8_t depth;
rbt_wlock(rbt);
depth = 0;
n = rbt_node_ptr(rbt->root);
if (n != NULL) {
rbt_walk_push(n);
while(depth > 0) {
n = rbt_node_ptr(rbt_walk_top()->_chld[RBT_NODE_SL]);
if (n != NULL)
rbt_walk_push(n);
else {
__in:
if (callback != NULL)
callback((void *)&(rbt_walk_top()->_node));
n = rbt_node_ptr(rbt_walk_top()->_chld[RBT_NODE_SR]);
free(rbt_walk_top());
if (n != NULL)
rbt_walk_top() = n;
else {
if (--depth > 0)
goto __in;
else
break;
}
}
}
}
rbt_wunlock(rbt);
rbt->root = NULL;
rbt->size = 0;
rbt->type = -1;
#if defined(RBT_IMPLICIT_LOCKING)
pthread_rwlock_destroy (&rbt->lock);
#endif
free (rbt);
return;
}
示例15: TEST
TEST(pthread, pthread_rwlock_smoke) {
pthread_rwlock_t l;
ASSERT_EQ(0, pthread_rwlock_init(&l, NULL));
// Single read lock
ASSERT_EQ(0, pthread_rwlock_rdlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
// Multiple read lock
ASSERT_EQ(0, pthread_rwlock_rdlock(&l));
ASSERT_EQ(0, pthread_rwlock_rdlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
// Write lock
ASSERT_EQ(0, pthread_rwlock_wrlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
// Try writer lock
ASSERT_EQ(0, pthread_rwlock_trywrlock(&l));
ASSERT_EQ(EBUSY, pthread_rwlock_trywrlock(&l));
ASSERT_EQ(EBUSY, pthread_rwlock_tryrdlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
// Try reader lock
ASSERT_EQ(0, pthread_rwlock_tryrdlock(&l));
ASSERT_EQ(0, pthread_rwlock_tryrdlock(&l));
ASSERT_EQ(EBUSY, pthread_rwlock_trywrlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
// Try writer lock after unlock
ASSERT_EQ(0, pthread_rwlock_wrlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
#ifdef __BIONIC__
// EDEADLK in "read after write"
ASSERT_EQ(0, pthread_rwlock_wrlock(&l));
ASSERT_EQ(EDEADLK, pthread_rwlock_rdlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
// EDEADLK in "write after write"
ASSERT_EQ(0, pthread_rwlock_wrlock(&l));
ASSERT_EQ(EDEADLK, pthread_rwlock_wrlock(&l));
ASSERT_EQ(0, pthread_rwlock_unlock(&l));
#endif
ASSERT_EQ(0, pthread_rwlock_destroy(&l));
}