VirtualBox

Changeset 101981 in vbox for trunk/src/libs/xpcom18a4


Ignore:
Timestamp:
Nov 8, 2023 2:07:52 PM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom: Convert plevent.{c,h} to IPRT critical sections and event semaphores, bugref:10545

Location:
trunk/src/libs/xpcom18a4/xpcom/threads
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c

    r101898 r101981  
    5252#include "private/pprthred.h"
    5353
     54#include <iprt/errcore.h>
     55
    5456static PRLogModuleInfo *event_lm = NULL;
    5557
     
    256258        int i, entryCount;
    257259
    258         event->lock = PR_NewLock();
    259         if (!event->lock) {
     260        int vrc = RTCritSectInit(&event->lock);
     261        if (RT_FAILURE(vrc)) {
    260262          return NULL;
    261263        }
    262         event->condVar = PR_NewCondVar(event->lock);
    263         if(!event->condVar) {
    264           PR_DestroyLock(event->lock);
    265           event->lock = NULL;
     264
     265        vrc = RTSemEventCreate(&event->condVar);
     266        if(RT_FAILURE(vrc))
     267        {
     268          RTCritSectDelete(&event->lock);
    266269          return NULL;
    267270        }
    268271
    269         PR_Lock(event->lock);
     272        RTCritSectEnter(&event->lock);
    270273
    271274        entryCount = PR_GetMonitorEntryCount(self->monitor);
     
    288291        while (!event->handled) {
    289292            /* wait for event to be handled or destroyed */
    290             PR_WaitCondVar(event->condVar, PR_INTERVAL_NO_TIMEOUT);
     293            RTCritSectLeave(&event->lock);
     294            RTSemEventWait(event->condVar, RT_INDEFINITE_WAIT);
     295            RTCritSectEnter(&event->lock);
    291296        }
    292297
     
    298303        result = event->synchronousResult;
    299304        event->synchronousResult = NULL;
    300         PR_Unlock(event->lock);
     305        RTCritSectLeave(&event->lock);
    301306    }
    302307
     
    386391
    387392        if (event->synchronousResult == (void*)PR_TRUE) {
    388             PR_Lock(event->lock);
     393            RTCritSectEnter(&event->lock);
    389394            event->synchronousResult = NULL;
    390395            event->handled = PR_TRUE;
    391             PR_NotifyCondVar(event->condVar);
    392             PR_Unlock(event->lock);
     396            RTSemEventSignal(event->condVar);
     397            RTCritSectLeave(&event->lock);
    393398        }
    394399        else {
     
    528533    self->synchronousResult = NULL;
    529534    self->handled = PR_FALSE;
    530     self->lock = NULL;
    531     self->condVar = NULL;
     535    self->condVar = NIL_RTSEMEVENT;
    532536#if defined(XP_UNIX) && !defined(XP_MACOSX)
    533537    self->id = 0;
     
    553557    result = self->handler(self);
    554558    if (NULL != self->synchronousResult) {
    555         PR_Lock(self->lock);
     559        RTCritSectEnter(&self->lock);
    556560        self->synchronousResult = result;
    557561        self->handled = PR_TRUE;
    558         PR_NotifyCondVar(self->condVar);
    559         PR_Unlock(self->lock);
     562        RTSemEventSignal(self->condVar);
     563        RTCritSectLeave(&self->lock);
    560564    }
    561565    else {
     
    575579    PR_ASSERT(PR_CLIST_IS_EMPTY(&self->link));
    576580
    577     if(self->condVar)
    578       PR_DestroyCondVar(self->condVar);
    579     if(self->lock)
    580       PR_DestroyLock(self->lock);
     581    if(self->condVar != NIL_RTSEMEVENT)
     582      RTSemEventDestroy(self->condVar);
     583    if(RTCritSectIsInitialized(&self->lock))
     584      RTCritSectDelete(&self->lock);
    581585
    582586    self->destructor(self);
  • trunk/src/libs/xpcom18a4/xpcom/threads/plevent.h

    r101898 r101981  
    188188#include "prclist.h"
    189189#include "prthread.h"
    190 #include "prlock.h"
    191190#include "prcvar.h"
    192191#include "prmon.h"
     192
     193#include <iprt/critsect.h>
     194#include <iprt/semaphore.h>
    193195
    194196#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
     
    526528    void*                               owner;
    527529    void*                               synchronousResult;
    528     PRLock*             lock;
    529     PRCondVar*          condVar;
     530    RTCRITSECT          lock;
     531    RTSEMEVENT          condVar;
    530532    PRBool              handled;
    531533#ifdef XP_UNIX
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette