VirtualBox

Changeset 22690 in vbox


Ignore:
Timestamp:
Sep 2, 2009 1:46:58 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51803
Message:

VBoxManageGuesProp.cpp: native wait on darwin.

File:
1 edited

Legend:

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

    r22686 r22690  
    4747#endif
    4848
     49#ifdef RT_OS_DARWIN
     50# include <CoreFoundation/CFRunLoop.h>
     51#endif
     52
    4953using namespace com;
    5054
     
    165169                                     IN_BSTR flags)
    166170    {
     171RTPrintf("OnGuestPropertyChange:\n");
    167172        Utf8Str utf8Name(name);
    168173        Guid uuid(machineId);
     
    482487
    483488#ifdef USE_XPCOM_QUEUE
    484     int const       fdQueue      = a->eventQ->GetEventQueueSelectFD();
    485 #endif
    486     uint64_t const  StartMilliTS = RTTimeMilliTS();
     489    int const       fdQueue   = a->eventQ->GetEventQueueSelectFD();
     490#endif
     491    uint64_t const  StartMsTS = RTTimeMilliTS();
    487492    for (;;)
    488493    {
     
    502507        else
    503508        {
    504             uint64_t cMsElapsed = RTTimeMilliTS() - StartMilliTS;
     509            uint64_t cMsElapsed = RTTimeMilliTS() - StartMsTS;
    505510            if (cMsElapsed >= cMsTimeout)
    506511                break; /* timeout */
     
    509514
    510515        /* Wait in a platform specific manner. */
     516#define POLL_MS_INTERVAL    1000
    511517#ifdef USE_XPCOM_QUEUE
    512518        fd_set fdset;
     
    515521        struct timeval tv;
    516522        if (    cMsLeft == RT_INDEFINITE_WAIT
    517             ||  cMsLeft >= 1000)
    518         {
    519             tv.tv_sec = 1;
     523            ||  cMsLeft >= POLL_MS_INTERVAL)
     524        {
     525            tv.tv_sec = POLL_MS_INTERVAL / 1000;
    520526            tv.tv_usec = 0;
    521527        }
     
    531537            break;
    532538        }
     539
     540#elif defined(RT_OS_DARWIN)
     541        CFTimeInterval rdTimeout = (double)RT_MIN(cMsLeft, POLL_MS_INTERVAL) / 1000;
     542        OSStatus orc = CFRunLoopRunInMode(kCFRunLoopDefaultMode, rdTimeout, true /*returnAfterSourceHandled*/);
     543        if (orc == kCFRunLoopRunHandledSource)
     544            orc = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, false /*returnAfterSourceHandled*/);
     545        if (   orc != 0
     546            && orc != kCFRunLoopRunHandledSource
     547            && orc != kCFRunLoopRunTimedOut)
     548        {
     549            RTPrintf("Error waiting for event: %d\n", orc);
     550            break;
     551        }
     552
    533553#else  /* !USE_XPCOM_QUEUE */
    534 /** @todo make this faster on Mac OS X (and possible Windows+OS/2 too), we should probably use WaitNextEvent() to wait here. */
    535         int vrc = cbImpl->wait(RT_MIN(cMsLeft, 1000));
     554        int vrc = cbImpl->wait(RT_MIN(cMsLeft, POLL_MS_INTERVAL));
    536555        if (    vrc != VERR_TIMEOUT
    537556            &&  RT_FAILURE(vrc))
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