VirtualBox

Changeset 22724 in vbox for trunk/src/libs/xpcom18a4


Ignore:
Timestamp:
Sep 2, 2009 3:20:30 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
51850
Message:

VBoxPython: com::EventQueue::processThreadEventQueue version of the code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp

    r22692 r22724  
    493493
    494494#ifdef VBOX
    495 # include <iprt/cdefs.h>
     495#define USE_EVENTQUEUE  1
     496
     497# ifdef USE_EVENTQUEUE
     498#  include <VBox/com/EventQueue.h>
     499#  include <iprt/err.h>
     500# else
     501#  include <iprt/cdefs.h>
     502# endif
    496503
    497504static nsIEventQueue* g_mainEventQ = nsnull;
    498505
     506# ifndef USE_EVENTQUEUE /** @todo Make USE_EVENTQUEUE default. */
    499507// Wrapper that checks if the queue has pending events.
    500508DECLINLINE(bool)
     
    616624
    617625# endif /* RT_OS_DARWIN */
     626# endif /* !USE_EVENTQUEUE */
    618627
    619628static PyObject*
     
    623632
    624633  if (!PyArg_ParseTuple(args, "i", &aTimeout))
    625     return NULL;
     634    return NULL; /** @todo throw exception */
    626635
    627636  nsIEventQueue* q = g_mainEventQ;
    628637  if (q == nsnull)
    629     return NULL;
    630 
     638    return NULL; /** @todo throw exception */
     639
     640# ifdef USE_EVENTQUEUE
     641  int rc = com::EventQueue::processThreadEventQueue(aTimeout < 0 ? RT_INDEFINITE_WAIT : (uint32_t)aTimeout);
     642  if (RT_SUCCESS(rc))
     643      return PyInt_FromLong(0);
     644  if (   rc == VERR_TIMEOUT
     645      || rc == VERR_INTERRUPTED)
     646      return PyInt_FromLong(1);
     647  return NULL; /** @todo throw exception */
     648
     649# else  /* !USE_EVENTQUEUE */
    631650  NS_WARN_IF_FALSE(isEventQueueNative(q), "The event queue must be native!");
    632651
    633652  PRInt32 result = 0;
    634 # ifdef RT_OS_DARWIN
     653#  ifdef RT_OS_DARWIN
    635654  if (aTimeout != 0 && !hasEventQueuePendingEvents(q))
    636655    result = waitForEventsOnDarwin(q, aTimeout);
     
    638657    q->ProcessPendingEvents();
    639658
    640 # else  /* !RT_OS_DARWIN */
     659#  else  /* !RT_OS_DARWIN */
    641660
    642661  PRBool hasEvents = PR_FALSE;
     
    693712 ok:
    694713  q->ProcessPendingEvents();
    695 # endif /* !RT_OS_DARWIN */
    696 
     714#  endif /* !RT_OS_DARWIN */
    697715  return PyInt_FromLong(result);
     716# endif /* !USE_EVENTQUEUE */
    698717}
    699718
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