VirtualBox

Changeset 46377 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Jun 4, 2013 11:59:37 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86196
Message:

Additions/x11/VBoxClient: a bit less busy waiting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/draganddrop.cpp

    r42320 r46377  
    8181# define DO(s) RTPrintf s
    8282#else
    83 # define DO(s) do {} while(0)
     83# define DO(s) do {} while (0)
    8484//# define DO(s) Log s
    8585#endif
     
    595595        XChangeProperty(m_pDisplay, m_proxyWin, xAtom(XA_XdndAware), XA_ATOM, 32, PropModeReplace,
    596596                        reinterpret_cast<unsigned char*>(&ver), 1);
    597     } while(0);
     597    } while (0);
    598598
    599599    m_state = Initialized;
     
    11371137            }
    11381138        }
    1139     } while(tries--);
     1139    } while (tries--);
    11401140    if (clme)
    11411141    {
     
    15031503}
    15041504
     1505#ifdef VBOX_WITH_DRAG_AND_DROP_GH
     1506
    15051507bool DragAndDropService::waitForXMsg(XEvent &ecm, int type, uint32_t uiMaxMS /* = 100 */)
    15061508{
     
    15301532//            return false;
    15311533    }
    1532     while(RTTimeProgramMilliTS() - uiStart < uiMaxMS);
     1534    while (RTTimeProgramMilliTS() - uiStart < uiMaxMS);
    15331535
    15341536    return false;
    15351537}
     1538
     1539#endif
    15361540
    15371541void DragAndDropService::clearEventQueue()
     
    15741578            RT_ZERO(e);
    15751579            if (m_eventQueue.isEmpty())
    1576                 rc = RTSemEventWait(m_hEventSem, 50);
     1580                rc = RTSemEventWait(m_hEventSem, RT_INDEFINITE_WAIT);
    15771581            if (!m_eventQueue.isEmpty())
    15781582            {
     
    16651669                }
    16661670            }
    1667         } while(!ASMAtomicReadBool(&m_fSrvStopping));
    1668     } while(0);
     1671        } while (!ASMAtomicReadBool(&m_fSrvStopping));
     1672    } while (0);
    16691673
    16701674    LogRelFlowFunc(("returning %Rrc\n", rc));
     
    16991703                            0, RTTHREADTYPE_MSG_PUMP, RTTHREADFLAGS_WAITABLE,
    17001704                            "X11-NOTIFY");
    1701     } while(0);
     1705    } while (0);
    17021706
    17031707    /* Cleanup on failure */
     
    17121716    /* Mark that we are stopping. */
    17131717    ASMAtomicWriteBool(&m_fSrvStopping, true);
    1714 
     1718    RTSemEventSignal(m_hEventSem);
     1719 
    17151720    if (m_pDisplay)
    17161721    {
     
    17271732                DO(("DnD_TERM: error sending xevent\n"));
    17281733    }
     1734   
     1735    /* We cannot signal the m_hHGCMThread as it is most likely waiting in vbglR3DoIOCtl() */
    17291736    /* Wait for our event threads to stop. */
    1730 //    if (m_hX11Thread)
    1731 //        RTThreadWait(m_hX11Thread, RT_INDEFINITE_WAIT, 0);
    1732 //    if (m_hHGCMThread)
    1733 //        RTThreadWait(m_hHGCMThread, RT_INDEFINITE_WAIT, 0);
     1737    if (m_hX11Thread)
     1738        RTThreadWait(m_hX11Thread, RT_INDEFINITE_WAIT, NULL);
    17341739    /* Cleanup */
    17351740    /* todo: This doesn't work. The semaphore was interrupted by the user
     
    17491754{
    17501755    AssertPtrReturn(pvUser, VERR_INVALID_PARAMETER);
    1751     DragAndDropService *pSrv = static_cast<DragAndDropService*>(pvUser);
     1756    DragAndDropService *pThis = static_cast<DragAndDropService*>(pvUser);
    17521757    DnDEvent e;
    17531758    do
     
    17591764        if (RT_SUCCESS(rc))
    17601765        {
    1761             pSrv->m_eventQueue.append(e);
    1762             rc = RTSemEventSignal(pSrv->m_hEventSem);
     1766            pThis->m_eventQueue.append(e);
     1767            rc = RTSemEventSignal(pThis->m_hEventSem);
    17631768            if (RT_FAILURE(rc))
    17641769                return rc;
    17651770        }
    1766     } while(!ASMAtomicReadBool(&pSrv->m_fSrvStopping));
     1771    } while (!ASMAtomicReadBool(&pThis->m_fSrvStopping));
    17671772
    17681773    return VINF_SUCCESS;
     
    17731778{
    17741779    AssertPtrReturn(pvUser, VERR_INVALID_PARAMETER);
    1775     DragAndDropService *pSrv = static_cast<DragAndDropService*>(pvUser);
     1780    DragAndDropService *pThis = static_cast<DragAndDropService*>(pvUser);
    17761781    DnDEvent e;
    17771782    do
     
    17821787         * events and if there are not any new one, sleep for a certain amount
    17831788         * of time. */
    1784         if (XEventsQueued(pSrv->m_pDisplay, QueuedAfterFlush) > 0)
     1789        if (XEventsQueued(pThis->m_pDisplay, QueuedAfterFlush) > 0)
    17851790        {
    17861791            RT_ZERO(e);
    17871792            e.type = DnDEvent::X11_Type;
    1788             XNextEvent(pSrv->m_pDisplay, &e.x11);
     1793            XNextEvent(pThis->m_pDisplay, &e.x11);
     1794#if 0
     1795            /* We never detect the stop event here for some reason */
    17891796            /* Check for a stop message. */
    1790 //            if (   e.x11.type == ClientMessage
    1791 //                && e.x11.xclient.message_type == xAtom(XA_dndstop))
    1792 //            {
    1793 //                break;
    1794 //            }
    1795 //            if (isDnDRespondEvent(pSrv->m_pDisplay, &e.x11, 0))
     1797            if (   e.x11.type == ClientMessage
     1798                && e.x11.xclient.message_type == xAtom(XA_dndstop))
     1799                break;
     1800#endif
     1801//            if (isDnDRespondEvent(pThis->m_pDisplay, &e.x11, 0))
    17961802            {
    17971803                /* Appending makes a copy of the event structure. */
    1798                 pSrv->m_eventQueue.append(e);
    1799                 int rc = RTSemEventSignal(pSrv->m_hEventSem);
     1804                pThis->m_eventQueue.append(e);
     1805                int rc = RTSemEventSignal(pThis->m_hEventSem);
    18001806                if (RT_FAILURE(rc))
    18011807                    return rc;
     
    18041810        else
    18051811            RTThreadSleep(25);
    1806     } while(!ASMAtomicReadBool(&pSrv->m_fSrvStopping));
     1812    } while (!ASMAtomicReadBool(&pThis->m_fSrvStopping));
    18071813
    18081814    return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

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