PR_IMPLEMENT(void) PRP_DestroyNakedCondVar(PRCondVar *cvar) { PR_ASSERT(cvar->condQ.next == &cvar->condQ); PR_ASSERT(_PR_NAKED_CV_LOCK == cvar->lock); _PR_MD_FREE_LOCK(&(cvar->ilock)); PR_DELETE(cvar); }
/* ** Destroy a condition variable. There must be no thread ** waiting on the condvar. The caller is responsible for guaranteeing ** that the condvar is no longer in use. ** */ PR_IMPLEMENT(void) PR_DestroyCondVar(PRCondVar *cvar) { PR_ASSERT(cvar->condQ.next == &cvar->condQ); #ifdef _PR_GLOBAL_THREADS_ONLY _PR_MD_FREE_CV(&cvar->md); #endif _PR_MD_FREE_LOCK(&(cvar->ilock)); PR_DELETE(cvar); }
PR_IMPLEMENT(PRStatus) PR_DestroyWaitGroup(PRWaitGroup *group) { PRStatus rv = PR_SUCCESS; if (NULL == group) group = mw_state->group; PR_ASSERT(NULL != group); if (NULL != group) { PR_Lock(group->ml); if ((group->waiting_threads == 0) && (group->waiter->count == 0) && PR_CLIST_IS_EMPTY(&group->io_ready)) { group->state = _prmw_stopped; } else { PR_SetError(PR_INVALID_STATE_ERROR, 0); rv = PR_FAILURE; } PR_Unlock(group->ml); if (PR_FAILURE == rv) return rv; PR_Lock(mw_lock); PR_REMOVE_LINK(&group->group_link); PR_Unlock(mw_lock); #ifdef WINNT /* * XXX make sure wait_list is empty and waiter is empty. * These must be checked while holding mdlock. */ _PR_MD_FREE_LOCK(&group->mdlock); #endif PR_DELETE(group->waiter); PR_DELETE(group->polling_list); PR_DestroyCondVar(group->mw_manage); PR_DestroyCondVar(group->new_business); PR_DestroyCondVar(group->io_complete); PR_DestroyCondVar(group->io_taken); PR_DestroyLock(group->ml); if (group == mw_state->group) mw_state->group = NULL; PR_DELETE(group); } else { /* The default wait group is not created yet. */ PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); rv = PR_FAILURE; } return rv; } /* PR_DestroyWaitGroup */
/* ** Destroy the given lock "lock". There is no point in making this race ** free because if some other thread has the pointer to this lock all ** bets are off. */ PR_IMPLEMENT(void) PR_DestroyLock(PRLock *lock) { PR_ASSERT(lock->owner == 0); _PR_MD_FREE_LOCK(&lock->ilock); PR_DELETE(lock); }
void _PR_FreeLock(PRLock *lock) { PR_ASSERT(lock->owner == 0); _PR_MD_FREE_LOCK(&lock->ilock); }