VirtualBox

Ignore:
Timestamp:
Nov 17, 2018 2:35:23 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
126697
Message:

Main/HGCM: Skip the handle stuff for the HGCMThread class, it just add overhead. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r75500 r75539  
    9090        static int sm_cServices;
    9191
    92         HGCMTHREADHANDLE m_thread;
    93         friend DECLCALLBACK(void) hgcmServiceThread(HGCMTHREADHANDLE ThreadHandle, void *pvUser);
     92        HGCMThread *m_pThread;
     93        friend DECLCALLBACK(void) hgcmServiceThread(HGCMThread *pThread, void *pvUser);
    9494
    9595        uint32_t volatile m_u32RefCnt;
     
    245245HGCMService::HGCMService()
    246246    :
    247     m_thread     (0),
     247    m_pThread    (NULL),
    248248    m_u32RefCnt  (0),
    249249    m_pSvcNext   (NULL),
     
    531531 * The service thread. Loads the service library and calls the service entry points.
    532532 */
    533 DECLCALLBACK(void) hgcmServiceThread(HGCMTHREADHANDLE ThreadHandle, void *pvUser)
     533DECLCALLBACK(void) hgcmServiceThread(HGCMThread *pThread, void *pvUser)
    534534{
    535535    HGCMService *pSvc = (HGCMService *)pvUser;
     
    541541    {
    542542        HGCMMsgCore *pMsgCore;
    543         int rc = hgcmMsgGet(ThreadHandle, &pMsgCore);
     543        int rc = hgcmMsgGet(pThread, &pMsgCore);
    544544
    545545        if (RT_FAILURE(rc))
     
    912912        RTStrCopy(szThreadName, sizeof(szThreadName), pszServiceName);
    913913
    914     int rc = hgcmThreadCreate(&m_thread, szThreadName, hgcmServiceThread, this, pszServiceName, pUVM);
     914    int rc = hgcmThreadCreate(&m_pThread, szThreadName, hgcmServiceThread, this, pszServiceName, pUVM);
    915915
    916916    if (RT_SUCCESS(rc))
     
    948948            /* Execute the load request on the service thread. */
    949949            HGCMMSGHANDLE hMsg;
    950             rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_LOAD, hgcmMessageAllocSvc);
     950            rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_LOAD, hgcmMessageAllocSvc);
    951951
    952952            if (RT_SUCCESS(rc))
     
    976976
    977977    HGCMMSGHANDLE hMsg;
    978     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_UNLOAD, hgcmMessageAllocSvc);
     978    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_UNLOAD, hgcmMessageAllocSvc);
    979979
    980980    if (RT_SUCCESS(rc))
     
    983983
    984984        if (RT_SUCCESS(rc))
    985         {
    986             hgcmThreadWait(m_thread);
    987         }
     985            hgcmThreadWait(m_pThread);
    988986    }
    989987
     
    10041002
    10051003    HGCMMSGHANDLE hMsg;
    1006     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_SAVESTATE, hgcmMessageAllocSvc);
     1004    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_SAVESTATE, hgcmMessageAllocSvc);
    10071005
    10081006    if (RT_SUCCESS(rc))
     
    10281026
    10291027    HGCMMSGHANDLE hMsg;
    1030     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_LOADSTATE, hgcmMessageAllocSvc);
     1028    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_LOADSTATE, hgcmMessageAllocSvc);
    10311029
    10321030    if (RT_SUCCESS(rc))
     
    14751473        HGCMMSGHANDLE hMsg;
    14761474
    1477         rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_CONNECT, hgcmMessageAllocSvc);
     1475        rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_CONNECT, hgcmMessageAllocSvc);
    14781476
    14791477        if (RT_SUCCESS(rc))
     
    15601558        HGCMMSGHANDLE hMsg;
    15611559
    1562         rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_DISCONNECT, hgcmMessageAllocSvc);
     1560        rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_DISCONNECT, hgcmMessageAllocSvc);
    15631561
    15641562        if (RT_SUCCESS(rc))
     
    15761574        {
    15771575            LogRel(("(%d, %d) [%s] hgcmMsgAlloc(%p, SVC_MSG_DISCONNECT) failed %Rrc\n",
    1578                     u32ClientId, fFromService, RT_VALID_PTR(m_pszSvcName)? m_pszSvcName: "", m_thread, rc));
     1576                    u32ClientId, fFromService, RT_VALID_PTR(m_pszSvcName)? m_pszSvcName: "", m_pThread, rc));
    15791577        }
    15801578    }
     
    15901588
    15911589            if (m_cClients > i)
    1592             {
    1593                 memmove (&m_paClientIds[i], &m_paClientIds[i + 1], sizeof(m_paClientIds[0]) * (m_cClients - i));
    1594             }
     1590                memmove(&m_paClientIds[i], &m_paClientIds[i + 1], sizeof(m_paClientIds[0]) * (m_cClients - i));
    15951591
    15961592            /* Delete the client handle. */
     
    16161612    /* Forward the message to the service thread. */
    16171613    HGCMMSGHANDLE hMsg = 0;
    1618     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_REGEXT, hgcmMessageAllocSvc);
     1614    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_REGEXT, hgcmMessageAllocSvc);
    16191615
    16201616    if (RT_SUCCESS(rc))
     
    16401636    /* Forward the message to the service thread. */
    16411637    HGCMMSGHANDLE hMsg = 0;
    1642     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_UNREGEXT, hgcmMessageAllocSvc);
     1638    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_UNREGEXT, hgcmMessageAllocSvc);
    16431639
    16441640    if (RT_SUCCESS(rc))
     
    16751671    LogFlow(("MAIN::HGCMService::Call\n"));
    16761672
    1677     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_GUESTCALL, hgcmMessageAllocSvc);
     1673    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_GUESTCALL, hgcmMessageAllocSvc);
    16781674
    16791675    if (RT_SUCCESS(rc))
     
    17181714
    17191715    HGCMMSGHANDLE hMsg = 0;
    1720     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_HOSTCALL, hgcmMessageAllocSvc);
     1716    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_HOSTCALL, hgcmMessageAllocSvc);
    17211717
    17221718    if (RT_SUCCESS(rc))
     
    17751771
    17761772    HGCMMSGHANDLE hMsg = 0;
    1777     int rc = hgcmMsgAlloc(m_thread, &hMsg, SVC_MSG_HOSTFASTCALLASYNC, hgcmMessageAllocSvc);
     1773    int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_HOSTFASTCALLASYNC, hgcmMessageAllocSvc);
    17781774
    17791775    if (RT_SUCCESS(rc))
     
    19391935
    19401936/* The main HGCM thread handler. */
    1941 static DECLCALLBACK(void) hgcmThread(HGCMTHREADHANDLE ThreadHandle, void *pvUser)
    1942 {
    1943     LogFlowFunc(("ThreadHandle = %p, pvUser = %p\n",
    1944                  ThreadHandle, pvUser));
     1937static DECLCALLBACK(void) hgcmThread(HGCMThread *pThread, void *pvUser)
     1938{
     1939    LogFlowFunc(("pThread = %p, pvUser = %p\n", pThread, pvUser));
    19451940
    19461941    NOREF(pvUser);
     
    19511946    {
    19521947        HGCMMsgCore *pMsgCore;
    1953         int rc = hgcmMsgGet(ThreadHandle, &pMsgCore);
     1948        int rc = hgcmMsgGet(pThread, &pMsgCore);
    19541949
    19551950        if (RT_FAILURE(rc))
     
    21922187 */
    21932188
    2194 /* The main hgcm thread. */
    2195 static HGCMTHREADHANDLE g_hgcmThread = 0;
     2189/** The main hgcm thread. */
     2190static HGCMThread *g_pHgcmThread = 0;
    21962191
    21972192/*
     
    22242219    HGCMMSGHANDLE hMsg = 0;
    22252220
    2226     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_LOAD, hgcmMainMessageAlloc);
     2221    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_LOAD, hgcmMainMessageAlloc);
    22272222
    22282223    if (RT_SUCCESS(rc))
     
    22682263    HGCMMSGHANDLE hMsg = 0;
    22692264
    2270     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_REGEXT, hgcmMainMessageAlloc);
     2265    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_REGEXT, hgcmMainMessageAlloc);
    22712266
    22722267    if (RT_SUCCESS(rc))
     
    22972292    HGCMMSGHANDLE hMsg = 0;
    22982293
    2299     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_UNREGEXT, hgcmMainMessageAlloc);
     2294    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_UNREGEXT, hgcmMainMessageAlloc);
    23002295
    23012296    if (RT_SUCCESS(rc))
     
    23402335    HGCMMSGHANDLE hMsg = 0;
    23412336
    2342     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_CONNECT, hgcmMainMessageAlloc);
     2337    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_CONNECT, hgcmMainMessageAlloc);
    23432338
    23442339    if (RT_SUCCESS(rc))
     
    23872382    HGCMMSGHANDLE hMsg = 0;
    23882383
    2389     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_DISCONNECT, hgcmMainMessageAlloc);
     2384    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_DISCONNECT, hgcmMainMessageAlloc);
    23902385
    23912386    if (RT_SUCCESS(rc))
     
    24212416    HGCMMSGHANDLE hMsg = 0;
    24222417
    2423     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, u32MsgId, hgcmMainMessageAlloc);
     2418    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, u32MsgId, hgcmMainMessageAlloc);
    24242419
    24252420    if (RT_SUCCESS(rc))
     
    25342529     * other non-time-critical functions.
    25352530     */
    2536     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_HOSTCALL, hgcmMainMessageAlloc);
     2531    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_HOSTCALL, hgcmMainMessageAlloc);
    25372532
    25382533    if (RT_SUCCESS(rc))
     
    25782573     * other non-time-critical functions.
    25792574     */
    2580     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_SVCAQUIRE, hgcmMainMessageAlloc);
     2575    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_SVCAQUIRE, hgcmMainMessageAlloc);
    25812576
    25822577    if (RT_SUCCESS(rc))
     
    26192614     * other non-time-critical functions.
    26202615     */
    2621     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_SVCRELEASE, hgcmMainMessageAlloc);
     2616    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_SVCRELEASE, hgcmMainMessageAlloc);
    26222617
    26232618    if (RT_SUCCESS(rc))
     
    26652660    HGCMMSGHANDLE hMsg = 0;
    26662661
    2667     int rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_RESET, hgcmMainMessageAlloc);
     2662    int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_RESET, hgcmMainMessageAlloc);
    26682663
    26692664    if (RT_SUCCESS(rc))
     
    26882683         */
    26892684
    2690         rc = hgcmThreadCreate(&g_hgcmThread, "MainHGCMthread", hgcmThread, NULL /*pvUser*/, NULL /*pszStatsSubDir*/, NULL /*pUVM*/);
     2685        rc = hgcmThreadCreate(&g_pHgcmThread, "MainHGCMthread", hgcmThread, NULL /*pvUser*/, NULL /*pszStatsSubDir*/, NULL /*pUVM*/);
    26912686
    26922687        if (RT_FAILURE(rc))
     
    27152710        HGCMMSGHANDLE hMsg = 0;
    27162711
    2717         rc = hgcmMsgAlloc(g_hgcmThread, &hMsg, HGCM_MSG_QUIT, hgcmMainMessageAlloc);
     2712        rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_QUIT, hgcmMainMessageAlloc);
    27182713
    27192714        if (RT_SUCCESS(rc))
     
    27242719            {
    27252720                /* Wait for the thread termination. */
    2726                 hgcmThreadWait(g_hgcmThread);
    2727                 g_hgcmThread = 0;
     2721                hgcmThreadWait(g_pHgcmThread);
     2722                g_pHgcmThread = 0;
    27282723
    27292724                hgcmThreadUninit();
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette