Changeset 101904 in vbox for trunk/src/libs/xpcom18a4/nsprpub
- Timestamp:
- Nov 6, 2023 8:59:26 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c
r101903 r101904 600 600 } /* PR_NotifyAll */ 601 601 602 /**************************************************************/603 /**************************************************************/604 /**************************SEMAPHORES**************************/605 /**************************************************************/606 /**************************************************************/607 PR_IMPLEMENT(void) PR_PostSem(PRSemaphore *semaphore)608 {609 static PRBool unwarned = PR_TRUE;610 if (unwarned) unwarned = _PR_Obsolete(611 "PR_PostSem", "locks & condition variables");612 PR_Lock(semaphore->cvar->lock);613 PR_NotifyCondVar(semaphore->cvar);614 semaphore->count += 1;615 PR_Unlock(semaphore->cvar->lock);616 } /* PR_PostSem */617 618 PR_IMPLEMENT(PRStatus) PR_WaitSem(PRSemaphore *semaphore)619 {620 PRStatus status = PR_SUCCESS;621 static PRBool unwarned = PR_TRUE;622 if (unwarned) unwarned = _PR_Obsolete(623 "PR_WaitSem", "locks & condition variables");624 PR_Lock(semaphore->cvar->lock);625 while ((semaphore->count == 0) && (PR_SUCCESS == status))626 status = PR_WaitCondVar(semaphore->cvar, PR_INTERVAL_NO_TIMEOUT);627 if (PR_SUCCESS == status) semaphore->count -= 1;628 PR_Unlock(semaphore->cvar->lock);629 return status;630 } /* PR_WaitSem */631 632 PR_IMPLEMENT(void) PR_DestroySem(PRSemaphore *semaphore)633 {634 static PRBool unwarned = PR_TRUE;635 if (unwarned) unwarned = _PR_Obsolete(636 "PR_DestroySem", "locks & condition variables");637 PR_DestroyLock(semaphore->cvar->lock);638 PR_DestroyCondVar(semaphore->cvar);639 PR_DELETE(semaphore);640 } /* PR_DestroySem */641 642 PR_IMPLEMENT(PRSemaphore*) PR_NewSem(PRUintn value)643 {644 PRSemaphore *semaphore;645 static PRBool unwarned = PR_TRUE;646 if (!_pr_initialized) _PR_ImplicitInitialization();647 648 if (unwarned) unwarned = _PR_Obsolete(649 "PR_NewSem", "locks & condition variables");650 651 semaphore = PR_NEWZAP(PRSemaphore);652 if (NULL != semaphore)653 {654 PRLock *lock = PR_NewLock();655 if (NULL != lock)656 {657 semaphore->cvar = PR_NewCondVar(lock);658 if (NULL != semaphore->cvar)659 {660 semaphore->count = value;661 return semaphore;662 }663 PR_DestroyLock(lock);664 }665 PR_DELETE(semaphore);666 }667 return NULL;668 }669 670 602 /* ptsynch.c */
Note:
See TracChangeset
for help on using the changeset viewer.