VirtualBox

Changeset 23083 in vbox for trunk/src


Ignore:
Timestamp:
Sep 17, 2009 11:12:44 AM (15 years ago)
Author:
vboxsync
Message:

VBoxManageGuestProp.cpp: make use of EventQueue::interruptEventQueueProcessing. calculate the wait unit correctly at the end of the time (nitpicking). style cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp

    r22914 r23083  
    168168            RTPrintf("Name: %lS, value: %lS, flags: %lS\n", name, value, flags);
    169169            ASMAtomicWriteBool(&mSignalled, true);
     170            com::EventQueue::getMainEventQueue()->interruptEventQueueProcessing();
    170171        }
    171172        return S_OK;
     
    442443
    443444    /*
    444      * Set up the callback and wait.
     445     * Set up the callback and loop until signal or timeout.
    445446     *
    446      * The waiting is done is 1 sec at the time since there there are races
    447      * between the callback and us going to sleep.  This also guards against
    448      * neglecting XPCOM event queues as well as any select timeout restrictions.
     447     * We do this in 1000 ms chunks to be on the safe side (there used to be
     448     * better reasons for it).
    449449     */
    450450    Bstr uuid;
     
    460460    a->virtualBox->RegisterCallback(callback);
    461461    uint64_t u64Started = RTTimeMilliTS();
    462     do {
    463       int vrc = com::EventQueue::getMainEventQueue()->processEventQueue(300);
    464       if (RT_FAILURE(vrc) && vrc != VERR_TIMEOUT)
    465       {
    466           RTPrintf("Error waiting for event: %Rrc\n", vrc);
    467           return 1;
    468       }
    469       if (cMsTimeout != RT_INDEFINITE_WAIT &&
    470           RTTimeMilliTS() - u64Started >= cMsTimeout)
    471             break;
    472     } while  (!cbImpl->Signalled());
     462    do
     463    {
     464        unsigned cMsWait;
     465        if (cMsTimeout == RT_INDEFINITE_WAIT)
     466            cMsWait = 1000;
     467        else
     468        {
     469            uint64_t cMsElapsed = RTTimeMilliTS() - u64Started;
     470            if (cMsElapsed >= cMsTimeout)
     471                break; /* timed out */
     472            cMsWait = RT_MIN(1000, (uint32_t)cMsTimeout - cMsElapsed);
     473        }
     474        int vrc = com::EventQueue::getMainEventQueue()->processEventQueue(cMsWait);
     475        if (    RT_FAILURE(vrc)
     476            &&  vrc != VERR_TIMEOUT)
     477        {
     478            RTPrintf("Error waiting for event: %Rrc\n", vrc);
     479            return 1;
     480        }
     481    } while (!cbImpl->Signalled());
    473482
    474483    a->virtualBox->UnregisterCallback(callback);
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