VirtualBox

Changeset 1788 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 29, 2007 8:02:32 AM (18 years ago)
Author:
vboxsync
Message:

Implemented hgcmThreadWait.

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

Legend:

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

    r1730 r1788  
    699699    {
    700700        rc = hgcmMsgSend (hMsg);
     701
     702        if (VBOX_SUCCESS (rc))
     703        {
     704            hgcmThreadWait (m_thread);
     705        }
    701706    }
    702707
     
    19471952            if (VBOX_SUCCESS (rc))
    19481953            {
     1954                /* Wait for the thread termination. */
     1955                hgcmThreadWait (g_hgcmThread);
     1956
    19491957                hgcmThreadUninit ();
    19501958            }
  • trunk/src/VBox/Main/hgcm/HGCMObjects.cpp

    r1779 r1788  
    209209            hgcmObjLeave ();
    210210        }
    211         else if (rc == VERR_SEM_DESTROYED)
    212         {
    213             /* @todo Implement hgcmThreadWait. */
    214         }
    215211        else
    216212        {
  • trunk/src/VBox/Main/hgcm/HGCMThread.cpp

    r1772 r1788  
    135135        HGCMThread ();
    136136
     137        int WaitForTermination (void);
     138
    137139        int Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser);
    138140
     
    199201
    200202    hgcmObjDeleteHandle (pThread->Handle ());
     203
     204    pThread->m_thread = NIL_RTTHREAD;
    201205
    202206    LogFlow(("MAIN::hgcmWorkerThreadFunc: completed HGCM thread %p\n", pThread));
     
    231235     */
    232236
     237    Assert(m_thread == NIL_RTTHREAD);
     238
    233239    if (RTCritSectIsInitialized (&m_critsect))
    234240    {
     
    246252    }
    247253
    248     /*
    249      * Wait for the thread to terminate, but let's not wait forever.
    250      */
    251     if (     m_thread != NIL_RTTHREAD
    252         && !(m_fu32ThreadFlags & HGCMMSG_TF_TERMINATED))
    253     {
    254         int rc = RTThreadWait (m_thread, 5000, NULL);
    255         AssertRC (rc);
    256     }
    257 
    258254    return;
     255}
     256
     257int HGCMThread::WaitForTermination (void)
     258{
     259    int rc = VINF_SUCCESS;
     260    LogFlowFunc(("\n"));
     261
     262    if (m_thread != NIL_RTTHREAD)
     263    {
     264        rc = RTThreadWait (m_thread, 5000, NULL);
     265    }
     266
     267    LogFlowFunc(("rc = %Vrc\n", rc));
     268    return rc;
    259269}
    260270
     
    648658}
    649659
     660int hgcmThreadWait (HGCMTHREADHANDLE hThread)
     661{
     662    int rc = VERR_INVALID_HANDLE;
     663    LogFlowFunc(("0x%08X\n", hThread));
     664
     665    HGCMThread *pThread = (HGCMThread *)hgcmObjReference (hThread, HGCMOBJ_THREAD);
     666
     667    if (pThread)
     668    {
     669        rc = pThread->WaitForTermination ();
     670
     671        hgcmObjDereference (pThread);
     672    }
     673
     674    LogFlowFunc(("rc = %Vrc\n", rc));
     675    return rc;
     676}
     677
    650678int hgcmMsgAlloc (HGCMTHREADHANDLE hThread, HGCMMSGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage)
    651679{
  • trunk/src/VBox/Main/include/hgcm/HGCMThread.h

    r1711 r1788  
    138138int hgcmThreadCreate (HGCMTHREADHANDLE *pHandle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser);
    139139
     140/** Wait for termination of a HGCM worker thread.
     141 *
     142 * @param handle The HGCM thread handle.
     143 *
     144 * @return VBox error code
     145 */
     146int hgcmThreadWait (HGCMTHREADHANDLE handle);
     147
    140148/** Allocate a message to be posted to HGCM worker thread.
    141149 *
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