VirtualBox

Ignore:
Timestamp:
Dec 16, 2011 12:02:38 AM (13 years ago)
Author:
vboxsync
Message:

xpcom18x4: Added code for using the IPRT request pool, currently disabled.

Location:
trunk/src/libs/xpcom18a4/ipc/ipcd
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp

    r39532 r39635  
    5353
    5454#ifdef VBOX
    55 #include <map>
    56 #include <list>
     55# include <map>
     56# include <list>
     57# include <iprt/err.h>
     58# include <iprt/req.h>
     59# include <iprt/mem.h>
    5760#endif /* VBOX */
    5861
    59 #if defined(DCONNECT_MULTITHREADED)
     62#if defined(DCONNECT_MULTITHREADED) && !defined(DCONNECT_WITH_IPRT_REQ_POOL)
    6063
    6164#include "nsIThread.h"
     
    28692872//-----------------------------------------------------------------------------
    28702873
    2871 #if defined(DCONNECT_MULTITHREADED)
     2874#if defined(DCONNECT_MULTITHREADED)  && !defined(DCONNECT_WITH_IPRT_REQ_POOL)
    28722875
    28732876class DConnectWorker : public nsIRunnable
     
    29772980}
    29782981
    2979 #endif // defined(DCONNECT_MULTITHREADED)
     2982#endif // defined(DCONNECT_MULTITHREADED) && !defined(DCONNECT_WITH_IPRT_REQ_POOL)
    29802983
    29812984//-----------------------------------------------------------------------------
     
    29862989 , mDisconnected(PR_TRUE)
    29872990 , mStubQILock(NULL)
     2991#if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     2992 , mhReqPool(NIL_RTREQPOOL)
     2993#endif
    29882994{
    29892995}
     
    30183024  PR_DestroyLock(mStubLock);
    30193025  PR_DestroyLock(mLock);
     3026#if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     3027  RTReqPoolRelease(mhReqPool);
     3028  mhReqPool = NIL_RTREQPOOL;
     3029#endif
    30203030}
    30213031
     
    30623072
    30633073#if defined(DCONNECT_MULTITHREADED)
     3074# if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     3075  int vrc = RTReqPoolCreate(1024 /*cMaxThreads*/, 10*RT_MS_1SEC /*cMsMinIdle*/,
     3076                            8 /*cThreadsPushBackThreshold */, RT_MS_1SEC /* cMsMaxPushBack */,
     3077                            "dconnect", &mhReqPool);
     3078  if (RT_FAILURE(vrc))
     3079  {
     3080    mhReqPool = NIL_RTREQPOOL;
     3081    return NS_ERROR_FAILURE;
     3082  }
     3083
     3084  /// @todo check where this is used.
     3085  mDisconnected = PR_FALSE;
     3086
     3087# else
    30643088
    30653089  mPendingMon = nsAutoMonitor::NewMonitor("DConnect pendingQ monitor");
     
    30863110  }
    30873111
     3112# endif
    30883113#else
    30893114
     
    31093134
    31103135#if defined(DCONNECT_MULTITHREADED)
     3136# if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     3137
     3138#  if defined(DCONNECT_STATS)
     3139  /// @todo print pool stats.
     3140#  endif
     3141
     3142  RTReqPoolRelease(mhReqPool);
     3143  mhReqPool = NIL_RTREQPOOL;
     3144
     3145# else
    31113146
    31123147  {
     
    31383173  nsAutoMonitor::DestroyMonitor(mPendingMon);
    31393174
     3175# endif
    31403176#endif
    31413177
     
    34103446
    34113447#if defined(DCONNECT_MULTITHREADED)
     3448# if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     3449
     3450  void *pvDataDup = RTMemDup(aData, aDataLen);
     3451  if (RT_UNLIKELY(!pvDataDup))
     3452    return NS_ERROR_OUT_OF_MEMORY;
     3453  int rc = RTReqPoolCallVoidNoWait(mhReqPool, (PFNRT)ProcessMessageOnWorkerThread, 4,
     3454                                   this, aSenderID, pvDataDup, aDataLen);
     3455  if (RT_FAILURE(rc))
     3456    return NS_ERROR_FAILURE;
     3457
     3458# else
    34123459
    34133460  nsAutoMonitor mon(mPendingMon);
     
    34413488  }
    34423489
     3490# endif
    34433491#else
    34443492
     
    35433591
    35443592//-----------------------------------------------------------------------------
     3593
     3594#if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     3595/**
     3596 * Function called by the request thread pool to process a incoming request in
     3597 * the context of a worker thread.
     3598 */
     3599/* static */ DECLCALLBACK(void)
     3600ipcDConnectService::ProcessMessageOnWorkerThread(ipcDConnectService *aThis, PRUint32 aSenderID, void *aData, PRUint32 aDataLen)
     3601{
     3602  if (!aThis->mDisconnected)
     3603    aThis->OnIncomingRequest(aSenderID, (const DConnectOp *)aData, aDataLen);
     3604  RTMemFree(aData);
     3605}
     3606#endif
    35453607
    35463608void
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.h

    r39341 r39635  
    4040#if !defined(DCONNECT_SINGLETHREADED) && !defined(DCONNECT_MULTITHREADED)
    4141#define DCONNECT_MULTITHREADED
     42# ifdef VBOX
     43//#  define DCONNECT_WITH_IPRT_REQ_POOL - needs testing
     44# endif
    4245#endif
    4346
     
    5962
    6063#if defined(DCONNECT_MULTITHREADED)
     64# if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     65
     66#  include <iprt/req.h>
     67
     68# else /* !DCONNECT_WITH_IPRT_REQ_POOL*/
    6169
    6270#include "ipcList.h"
     
    8088};
    8189
     90# endif // !DCONNECT_WITH_IPRT_REQ_POOL
    8291#endif // DCONNECT_MULTITHREADED
    8392
     
    275284
    276285#if defined(DCONNECT_MULTITHREADED)
     286# if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     287  static DECLCALLBACK(void) ProcessMessageOnWorkerThread(ipcDConnectService *aThis, PRUint32 aSenderID, void *aData, PRUint32 aDataLen);
     288# else
    277289  NS_HIDDEN_(nsresult) CreateWorker();
     290# endif
    278291#endif
    279292
     
    310323
    311324#if defined(DCONNECT_MULTITHREADED)
     325# if defined(DCONNECT_WITH_IPRT_REQ_POOL)
     326
     327  /** Request pool. */
     328  RTREQPOOL mhReqPool;
     329
     330# else
    312331
    313332  friend class DConnectWorker;
     
    323342  // monitor used to wait on changes in mWaitingWorkers.
    324343  PRMonitor *mWaitingWorkersMon;
    325 
     344# endif
    326345#endif
    327346
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