VirtualBox

Changeset 20630 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jun 16, 2009 1:55:38 PM (15 years ago)
Author:
vboxsync
Message:

Python: moved waiting on client side, removed main API for event waiting, as making no sense

Location:
trunk/src/VBox/Main
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r20598 r20630  
    18911891}
    18921892
    1893 
    1894 STDMETHODIMP VirtualBox::WaitForEvents(LONG aTimeout)
    1895 {
    1896 #ifdef RT_OS_WINDOWS
    1897     ReturnComNotImplemented();
    1898 #else
    1899     extern nsresult XPCOM_waitForEvents(PRInt32 aTimeout);
    1900 
    1901     return XPCOM_waitForEvents(aTimeout);
    1902 #endif
    1903 }
    19041893
    19051894STDMETHODIMP VirtualBox::WaitForPropertyChange (IN_BSTR /* aWhat */, ULONG /* aTimeout */,
  • trunk/src/VBox/Main/glue/vboxapi.py

    r20598 r20630  
    145145        return d['result']
    146146
     147    def waitForEvents(self, timeout):
     148        # not really supported yet
     149        pass
     150
     151    def deinit(self):
     152        import pythoncom
     153        pythoncom.CoUninitialize()
     154        pass
     155
    147156class PlatformXPCOM:
    148157    def __init__(self, params):
     
    192201        return d['result']
    193202
     203    def waitForEvents(self, timeout):
     204        import xpcom
     205        xpcom._xpcom.WaitForEvents(timeout)
     206
     207    def deinit(self):
     208        import xpcom
     209        xpcom._xpcom.DeinitCOM()
    194210
    195211class PlatformWEBSERVICE:
     
    235251    def createCallback(self, iface, impl, arg):
    236252        raise Exception("no callbacks for webservices")
     253
     254    def waitForEvents(self, timeout):
     255        # Webservices cannot do that
     256        pass
     257
     258    def deinit(self):
     259        # should we do something about it?
     260        pass
    237261
    238262class SessionManager:
     
    269293
    270294    def __del__(self):
     295        deinit(self)
     296
     297    def deinit(self):
    271298        if hasattr(self, "vbox"):
    272299            del self.vbox
     300        if hasattr(self, "platform"):
     301            self.platform.deinit()
    273302
    274303    def initPerThread(self):
     
    288317    def createCallback(self, iface, impl, arg):
    289318        return self.platform.createCallback(iface, impl, arg)
     319
     320    def waitForEvents(self, timeout):
     321        return self.platform.waitForEvents(timeout)
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r20598 r20630  
    26442644      <param name="callback" type="IVirtualBoxCallback" dir="in">
    26452645        <desc>Callback object to unregister.</desc>
    2646       </param>
    2647     </method>
    2648 
    2649     <method name="waitForEvents">
    2650       <desc>
    2651         Blocking wait for events to happen and process them, if any.
    2652         One may wish to call this method from the main even loop
    2653         to wait for acitivity from VirtualBox, such as callback calling.
    2654       </desc>
    2655       <param name="timeout" type="long" dir="in">
    2656         <desc>
    2657           Wait timeout in milliseconds.
    2658           Specify -1 for an indefinite wait.
    2659           Specify 0 for immediate return if no events to process.
    2660         </desc>
    26612646      </param>
    26622647    </method>
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r20598 r20630  
    180180    STDMETHOD(UnregisterCallback) (IVirtualBoxCallback *aCallback);
    181181
    182     STDMETHOD(WaitForEvents) (LONG aTimeout);   
    183182    STDMETHOD(WaitForPropertyChange) (IN_BSTR aWhat, ULONG aTimeout,
    184183                                      BSTR *aChanged, BSTR *aValues);
  • trunk/src/VBox/Main/xpcom/server.cpp

    r20598 r20630  
    244244static PRBool volatile gKeepRunning = PR_TRUE;
    245245
    246 nsresult XPCOM_waitForEvents(PRInt32 aTimeout)
    247 {
    248   nsIEventQueue* q = gEventQ;
    249   PRBool hasEvents = false;
    250   nsresult rc;
    251 
    252   if (!gKeepRunning || !q)
    253     return NS_OK;
    254 
    255   rc = q->PendingEvents(&hasEvents);
    256   if (NS_FAILED (rc))
    257     return NS_ERROR_FAILURE;
    258 
    259   if (hasEvents)
    260   {
    261     q->ProcessPendingEvents();
    262     return NS_OK;
    263   }
    264  
    265   if (aTimeout == 0)
    266      return NS_OK;
    267 
    268   PRInt32 fd;
    269   fd = q->GetEventQueueSelectFD();
    270 
    271   if (fd < 0 && aTimeout == -1)
    272   {
    273     /* fallback */
    274     PLEvent *pEvent = NULL;
    275     rc = q->WaitForEvent(&pEvent);
    276     if (NS_SUCCEEDED(rc))
    277       q->HandleEvent(pEvent);
    278 
    279     q->ProcessPendingEvents();
    280     return NS_OK;
    281   }
    282 
    283   /* Cannot perform timed wait otherwise */
    284   AssertReturn(fd >= 0, NS_ERROR_FAILURE);
    285  
    286   fd_set fdsetR, fdsetE;
    287   struct timeval tv;
    288 
    289   FD_ZERO(&fdsetR);
    290   FD_SET(fd, &fdsetR);
    291 
    292   fdsetE = fdsetR;
    293   if (aTimeout > 0)
    294   {
    295     /* LogRel(("sleep %d\n", aTimeout)); */
    296     tv.tv_sec = (PRInt64)aTimeout / 1000;
    297     tv.tv_usec = ((PRInt64)aTimeout % 1000) * 1000;
    298   }
    299 
    300   /** @todo: What to do for XPCOM platforms w/o select() ? */
    301   int n = select(fd + 1, &fdsetR, NULL, &fdsetE, aTimeout < 0 ? NULL : &tv);
    302   rc = (n >= 0) ? NS_OK :  NS_ERROR_FAILURE;
    303 
    304   /* process pending events, no matter what */
    305   q->ProcessPendingEvents();
    306 
    307   return rc;
    308 }
    309 
    310246/////////////////////////////////////////////////////////////////////////////
    311247
     
    776712
    777713/**
    778  * Hhelper function to register self components upon start-up
     714 * Helper function to register self components upon start-up
    779715 * of the out-of-proc server.
    780716 */
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