VirtualBox

Changeset 10779 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 21, 2008 2:29:29 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
33550
Message:

Locking. Enabled tests in tstAPI.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/PerformanceImpl.cpp

    r10770 r10779  
    231231        LogFlow (("PerformanceCollector::GetMetrics() store a metric at "
    232232                  "retMetrics[%d]...\n", i));
    233         metric.queryInterfaceTo (&retMetrics [++ i]);
     233        metric.queryInterfaceTo (&retMetrics [i++]);
    234234    }
    235235    retMetrics.detachTo (ComSafeArrayOutArg(outMetrics));
     
    274274
    275275    AutoReadLock alock (this); /* Need a read lock to access mBaseMetrics */
     276                               /* Write lock is not needed since we are */
     277                               /* fiddling with enable bit only. No harm */
     278                               /* the readers may see it differently. */
    276279
    277280    BaseMetricList::iterator it;
     
    295298    /// @todo (r=dmik) why read lock below? individual elements get modified!
    296299
    297     AutoReadLock alock (this);
     300    AutoReadLock alock (this); /* Need a read lock to access mBaseMetrics */
     301                               /* Write lock is not needed since we are */
     302                               /* fiddling with enable bit only. No harm */
     303                               /* the readers may see it differently. */
    298304
    299305    BaseMetricList::iterator it;
     
    365371void PerformanceCollector::registerBaseMetric (pm::BaseMetric *baseMetric)
    366372{
    367     /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure
    368     /// the object is not uninitialized while you are doing something here
     373    AutoCaller autoCaller (this);
     374    if (!SUCCEEDED (autoCaller.rc())) return;
    369375
    370376    AutoWriteLock alock (this);
     
    374380void PerformanceCollector::registerMetric (pm::Metric *metric)
    375381{
    376     /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure
    377     /// the object is not uninitialized while you are doing something here
     382    AutoCaller autoCaller (this);
     383    if (!SUCCEEDED (autoCaller.rc())) return;
    378384
    379385    AutoWriteLock alock (this);
     
    383389void PerformanceCollector::unregisterBaseMetricsFor (const ComPtr <IUnknown> &aObject)
    384390{
    385     /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure
    386     /// the object is not uninitialized while you are doing something here
     391    AutoCaller autoCaller (this);
     392    if (!SUCCEEDED (autoCaller.rc())) return;
    387393
    388394    AutoWriteLock alock (this);
     
    394400void PerformanceCollector::unregisterMetricsFor (const ComPtr <IUnknown> &aObject)
    395401{
    396     /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure
    397     /// the object is not uninitialized while you are doing something here
     402    AutoCaller autoCaller (this);
     403    if (!SUCCEEDED (autoCaller.rc())) return;
    398404
    399405    AutoWriteLock alock (this);
     
    436442////////////////////////////////////////////////////////////////////////////////
    437443
    438 PerformanceMetric::PerformanceMetric() : mMetric(0)
     444PerformanceMetric::PerformanceMetric()
    439445{
    440446}
     
    463469HRESULT PerformanceMetric::init (pm::Metric *aMetric)
    464470{
    465     mMetric = aMetric;
     471    m.name   = aMetric->getName();
     472    m.object = aMetric->getObject();
     473    m.period = aMetric->getPeriod();
     474    m.count  = aMetric->getLength();
     475    m.unit   = aMetric->getUnit();
     476    m.min    = aMetric->getMinValue();
     477    m.max    = aMetric->getMaxValue();
    466478    return S_OK;
    467479}
     
    476488    /// AutoReadLock? Is the underlying metric a constant object?
    477489
    478     Bstr tmp (mMetric->getName());
    479     tmp.detachTo (aMetricName);
     490    m.name.cloneTo (aMetricName);
    480491    return S_OK;
    481492}
     
    483494STDMETHODIMP PerformanceMetric::COMGETTER(Object) (IUnknown **anObject)
    484495{
    485     *anObject = mMetric->getObject();
     496    m.object.queryInterfaceTo(anObject);
    486497    return S_OK;
    487498}
     
    489500STDMETHODIMP PerformanceMetric::COMGETTER(Period) (ULONG *aPeriod)
    490501{
    491     *aPeriod = mMetric->getPeriod();
     502    *aPeriod = m.period;
    492503    return S_OK;
    493504}
     
    495506STDMETHODIMP PerformanceMetric::COMGETTER(Count) (ULONG *aCount)
    496507{
    497     *aCount = mMetric->getLength();
     508    *aCount = m.count;
    498509    return S_OK;
    499510}
     
    501512STDMETHODIMP PerformanceMetric::COMGETTER(Unit) (BSTR *aUnit)
    502513{
    503     Bstr tmp (mMetric->getUnit());
    504     tmp.detachTo(aUnit);
     514    m.unit.cloneTo(aUnit);
    505515    return S_OK;
    506516}
     
    508518STDMETHODIMP PerformanceMetric::COMGETTER(MinimumValue) (LONG *aMinValue)
    509519{
    510     *aMinValue = mMetric->getMinValue();
     520    *aMinValue = m.min;
    511521    return S_OK;
    512522}
     
    514524STDMETHODIMP PerformanceMetric::COMGETTER(MaximumValue) (LONG *aMaxValue)
    515525{
    516     *aMaxValue = mMetric->getMaxValue();
    517     return S_OK;
    518 }
    519 
     526    *aMaxValue = m.max;
     527    return S_OK;
     528}
     529
  • trunk/src/VBox/Main/include/PerformanceImpl.h

    r10770 r10779  
    5050    public IPerformanceMetric
    5151{
    52 private:
    53 
    54     struct Data
    55     {
    56         /* Constructor. */
    57         Data() { }
    58 
    59         bool operator== (const Data &that) const
    60         {
    61             return this == &that;
    62         }
    63     };
    64 
    6552public:
    6653
     
    10289private:
    10390
    104     pm::Metric *mMetric;
     91    struct Data
     92    {
     93        /* Constructor. */
     94        Data() : period(0), count(0), min(0), max(0) { }
     95
     96        Bstr             name;
     97        ComPtr<IUnknown> object;
     98        ULONG            period;
     99        ULONG            count;
     100        Bstr             unit;
     101        LONG             min;
     102        LONG             max;
     103    };
     104
     105    Data m;
    105106};
    106107
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r10753 r10779  
    926926#endif
    927927
    928 #if 0
     928#if 1
    929929    do {
    930930        // Get collector
     
    10171017}
    10181018
    1019 #if 0
     1019#if 1
    10201020void queryMetrics (ComPtr <IPerformanceCollector> collector,
    10211021                   ComSafeArrayIn (IUnknown *, objects))
     
    10531053        Bstr metricUnit(metricUnitBSTR);
    10541054        Bstr metricName(retNames[i]);
    1055         printf("%ls", metricName.raw());
     1055        printf("obj(%p) %ls", anObject[0], metricName.raw());
    10561056        for (unsigned j = 0; j < retLengths[i]; j++)
    10571057        {
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