VirtualBox

Changeset 1344 in vbox for trunk


Ignore:
Timestamp:
Mar 8, 2007 6:13:39 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
19321
Message:

Disabled obsolete code in HGCM, added logging.

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

Legend:

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

    r1301 r1344  
    6969#define HGCMMSG_TF_TERMINATED          (0x00000004)
    7070
     71/** @todo consider use of RTReq */
    7172
    7273static DECLCALLBACK(int) hgcmWorkerThreadFunc (RTTHREAD ThreadSelf, void *pvUser);
     
    100101        uint32_t m_fu32ThreadFlags;
    101102
    102         /* Typical message size for this thread, messages with
    103          * this size will be put in the Free list and reused,
    104          * instead of reallocating. Should speed up processing
    105          * in cases when the message size is fixed.
    106          */
    107         uint32_t m_cbMsg;
    108 
    109103        /* Message queue variables. Messages are inserted at tail of message
    110104         * queue. They are consumed by worker thread sequently. If a message was
     
    146140        int MsgPost (HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback, bool bWait);
    147141        void MsgComplete (HGCMMsgCore *pMsg, int32_t result);
    148 
    149         bool MsgReuse (HGCMMsgCore *pMsg);
    150142};
    151143
     
    161153void HGCMMsgCore::InitializeCore (uint32_t cbMsg, uint32_t u32MsgId, HGCMThread *pThread)
    162154{
    163     m_cbMsg       = cbMsg;
    164155    m_u32Version  = HGCMMSG_VERSION;
    165156    m_u32Msg      = u32MsgId;
     
    171162
    172163    m_pThread     = pThread;
    173 }
    174 
    175 bool HGCMMsgCore::Reuse (void)
    176 {
    177     return m_pThread->MsgReuse (this);
    178164}
    179165
     
    218204    m_eventSend (0),
    219205    m_fu32ThreadFlags (0),
    220     m_cbMsg (0),
    221206    m_pMsgInputQueueHead (NULL),
    222207    m_pMsgInputQueueTail (NULL),
     
    281266                m_pfnThread = pfnThread;
    282267                m_pvUser    = pvUser;
    283                 m_cbMsg     = cbMsg;
    284268
    285269                m_fu32ThreadFlags = HGCMMSG_TF_INITIALIZING;
     
    352336    bool fFromFreeList = false;
    353337
    354 #if 0 /* @todo to be replaced with RTReq */
    355     if (cbMsg == m_cbMsg)
    356     {
    357         rc = Enter ();
    358 
    359         if (VBOX_SUCCESS(rc))
    360         {
    361             /* May be we can reuse a previously allocated message memory block. */
    362 
    363             if (m_pFreeHead)
    364             {
    365                 /* Take existing message object from the head of the free list. */
    366                 pmsg = m_pFreeHead;
    367 
    368                 m_pFreeHead = m_pFreeHead->m_pNext;
    369 
    370                 if (m_pFreeHead == NULL)
    371                 {
    372                     m_pFreeTail = NULL;
    373                 }
    374 
    375                 fFromFreeList = true;
    376             }
    377 
    378             Leave ();
    379         }
    380     }
    381 #endif
    382 
    383338    if (!pmsg && VBOX_SUCCESS(rc))
    384339    {
     
    397352        Reference ();
    398353
    399         /* Initialize just allocated or reused message core */
     354        /* Initialize just allocated message core */
    400355        pmsg->InitializeCore (cbMsg, u32MsgId, this);
    401356
     
    632587}
    633588
    634 
    635 bool HGCMThread::MsgReuse (HGCMMsgCore *pMsg)
    636 {
    637     if (pMsg->m_cbMsg != m_cbMsg)
    638     {
    639         /* Message no longer belong to the thread. */
    640         Dereference ();
    641 
    642         return false;
    643     }
    644 
    645     int rc = Enter ();
    646 
    647     if (VBOX_SUCCESS (rc))
    648     {
    649         /* Put the message to the tail of free list. */
    650 
    651         /* Reference message because it will still be in free list. */
    652         pMsg->Reference ();
    653 
    654         pMsg->Uninitialize ();
    655 
    656         if (m_pFreeTail)
    657         {
    658             m_pFreeTail->m_pNext = pMsg;
    659         }
    660         else
    661         {
    662             m_pFreeHead = pMsg;
    663         }
    664 
    665         m_pFreeTail = pMsg;
    666 
    667         Leave ();
    668 
    669         /* Dereference the thread. */
    670         Dereference ();
    671     }
    672 
    673     return true;
    674 }
    675 
    676 
    677 
    678589/*
    679590 * Thread API. Public interface.
  • trunk/src/VBox/Main/include/hgcm/HGCMObjects.h

    r1080 r1344  
    2222#ifndef __HGCMOBJECTS__H
    2323#define __HGCMOBJECTS__H
     24
     25#define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_HGCM
     26#include "Logging.h"
    2427
    2528#include <iprt/assert.h>
     
    5457        ObjectAVLCore Core;
    5558
    56         virtual bool Reuse (void) { return false; };
    57 
    5859    protected:
    5960        virtual ~HGCMObject (void) {};
     
    6768        void Reference (void)
    6869        {
    69             ASMAtomicIncS32 (&cRef);
     70            int32_t refCnt = ASMAtomicIncS32 (&cRef);
     71           
     72            Log(("Reference: refCnt = %d\n", refCnt));
    7073        }
    7174
     
    7477            int32_t refCnt = ASMAtomicDecS32 (&cRef);
    7578
     79            Log(("Dereference: refCnt = %d\n", refCnt));
     80           
    7681            AssertRelease(refCnt >= 0);
    7782
     
    8186            }
    8287
    83             if (!Reuse ())
    84             {
    85                 delete this;
    86             }
     88            delete this;
    8789        }
    8890
  • trunk/src/VBox/Main/include/hgcm/HGCMThread.h

    r1080 r1344  
    6161        friend class HGCMThread;
    6262
    63         /** Size of entire message block. */
    64         uint32_t m_cbMsg;
    65 
    6663        /** Version of message header. */
    6764        uint32_t m_u32Version;
     
    8986        void InitializeCore (uint32_t cbMsg, uint32_t u32MsgId, HGCMThread *pThread);
    9087
    91         virtual bool Reuse (void);
    92 
    9388    protected:
    9489        virtual ~HGCMMsgCore () {};
     
    10196        HGCMThread *Thread (void) { return m_pThread; };
    10297
    103         /** Initialize message after it was allocated or reused. */
     98        /** Initialize message after it was allocated. */
    10499        virtual void Initialize (void) {};
    105100
    106         /** Uninitialize message, message will then be freed or put to
    107          * a list, from where it can be reused.
    108          */
     101        /** Uninitialize message. */
    109102        virtual void Uninitialize (void) {};
    110103
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