Changeset 101981 in vbox for trunk/src/libs/xpcom18a4
- Timestamp:
- Nov 8, 2023 2:07:52 PM (15 months ago)
- Location:
- trunk/src/libs/xpcom18a4/xpcom/threads
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/threads/plevent.c
r101898 r101981 52 52 #include "private/pprthred.h" 53 53 54 #include <iprt/errcore.h> 55 54 56 static PRLogModuleInfo *event_lm = NULL; 55 57 … … 256 258 int i, entryCount; 257 259 258 event->lock = PR_NewLock();259 if ( !event->lock) {260 int vrc = RTCritSectInit(&event->lock); 261 if (RT_FAILURE(vrc)) { 260 262 return NULL; 261 263 } 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); 266 269 return NULL; 267 270 } 268 271 269 PR_Lock(event->lock);272 RTCritSectEnter(&event->lock); 270 273 271 274 entryCount = PR_GetMonitorEntryCount(self->monitor); … … 288 291 while (!event->handled) { 289 292 /* 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); 291 296 } 292 297 … … 298 303 result = event->synchronousResult; 299 304 event->synchronousResult = NULL; 300 PR_Unlock(event->lock);305 RTCritSectLeave(&event->lock); 301 306 } 302 307 … … 386 391 387 392 if (event->synchronousResult == (void*)PR_TRUE) { 388 PR_Lock(event->lock);393 RTCritSectEnter(&event->lock); 389 394 event->synchronousResult = NULL; 390 395 event->handled = PR_TRUE; 391 PR_NotifyCondVar(event->condVar);392 PR_Unlock(event->lock);396 RTSemEventSignal(event->condVar); 397 RTCritSectLeave(&event->lock); 393 398 } 394 399 else { … … 528 533 self->synchronousResult = NULL; 529 534 self->handled = PR_FALSE; 530 self->lock = NULL; 531 self->condVar = NULL; 535 self->condVar = NIL_RTSEMEVENT; 532 536 #if defined(XP_UNIX) && !defined(XP_MACOSX) 533 537 self->id = 0; … … 553 557 result = self->handler(self); 554 558 if (NULL != self->synchronousResult) { 555 PR_Lock(self->lock);559 RTCritSectEnter(&self->lock); 556 560 self->synchronousResult = result; 557 561 self->handled = PR_TRUE; 558 PR_NotifyCondVar(self->condVar);559 PR_Unlock(self->lock);562 RTSemEventSignal(self->condVar); 563 RTCritSectLeave(&self->lock); 560 564 } 561 565 else { … … 575 579 PR_ASSERT(PR_CLIST_IS_EMPTY(&self->link)); 576 580 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); 581 585 582 586 self->destructor(self); -
trunk/src/libs/xpcom18a4/xpcom/threads/plevent.h
r101898 r101981 188 188 #include "prclist.h" 189 189 #include "prthread.h" 190 #include "prlock.h"191 190 #include "prcvar.h" 192 191 #include "prmon.h" 192 193 #include <iprt/critsect.h> 194 #include <iprt/semaphore.h> 193 195 194 196 #ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP … … 526 528 void* owner; 527 529 void* synchronousResult; 528 PRLock*lock;529 PRCondVar*condVar;530 RTCRITSECT lock; 531 RTSEMEVENT condVar; 530 532 PRBool handled; 531 533 #ifdef XP_UNIX
Note:
See TracChangeset
for help on using the changeset viewer.