- Timestamp:
- Jun 2, 2010 11:25:57 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/hgcm/HGCMThread.cpp
r28800 r29976 90 90 /* A caller thread waits for completion of a SENT message on this event. */ 91 91 RTSEMEVENTMULTI m_eventSend; 92 int32_t volatile m_i32MessagesProcessed; 92 93 93 94 /* Critical section for accessing the thread data, mostly for message queues. */ … … 213 214 m_eventThread (0), 214 215 m_eventSend (0), 216 m_i32MessagesProcessed (0), 215 217 m_fu32ThreadFlags (0), 216 218 m_pMsgInputQueueHead (NULL), … … 433 435 if (fWait) 434 436 { 437 /* Immediately check if the message has been processed. */ 435 438 while ((pMsg->m_fu32Flags & HGCM_MSG_F_PROCESSED) == 0) 436 439 { 437 RTSemEventMultiWait (m_eventSend, RT_INDEFINITE_WAIT); 440 /* Poll infrequently to make sure no completed message has been missed. */ 441 RTSemEventMultiWait (m_eventSend, 1000); 442 443 LogFlow(("HGCMThread::MsgPost: wait completed flags = %08X\n", pMsg->m_fu32Flags)); 444 445 if ((pMsg->m_fu32Flags & HGCM_MSG_F_PROCESSED) == 0) 446 { 447 RTThreadYield(); 448 } 449 } 450 451 /* 'Our' message has been processed, so should reset the semaphore. 452 * There is still possible that another message has been processed 453 * and the semaphore has been signalled again. 454 * Reset only if there are no other messages completed. 455 */ 456 int32_t c = ASMAtomicDecS32(&m_i32MessagesProcessed); 457 Assert(c >= 0); 458 if (c == 0) 459 { 438 460 RTSemEventMultiReset (m_eventSend); 439 440 LogFlow(("HGCMThread::MsgPost: wait completed flags = %08X\n", pMsg->m_fu32Flags));441 461 } 442 462 … … 581 601 bool fWaited = ((pMsg->m_fu32Flags & HGCM_MSG_F_WAIT) != 0); 582 602 603 if (fWaited) 604 { 605 ASMAtomicIncS32(&m_i32MessagesProcessed); 606 607 /* This should be done before setting the HGCM_MSG_F_PROCESSED flag. */ 608 pMsg->m_rcSend = result; 609 } 610 583 611 /* The message is now completed. */ 584 612 pMsg->m_fu32Flags &= ~HGCM_MSG_F_IN_PROCESS; … … 592 620 if (fWaited) 593 621 { 594 /* If message is being waited, then it is referenced by the waiter and the pointer595 * if valid even after hgcmObjDeleteHandle.596 */597 pMsg->m_rcSend = result;598 599 622 /* Wake up all waiters. so they can decide if their message has been processed. */ 600 623 RTSemEventMultiSignal (m_eventSend);
Note:
See TracChangeset
for help on using the changeset viewer.