Changeset 10779 in vbox for trunk/src/VBox
- Timestamp:
- Jul 21, 2008 2:29:29 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 33550
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/PerformanceImpl.cpp
r10770 r10779 231 231 LogFlow (("PerformanceCollector::GetMetrics() store a metric at " 232 232 "retMetrics[%d]...\n", i)); 233 metric.queryInterfaceTo (&retMetrics [ ++ i]);233 metric.queryInterfaceTo (&retMetrics [i++]); 234 234 } 235 235 retMetrics.detachTo (ComSafeArrayOutArg(outMetrics)); … … 274 274 275 275 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. */ 276 279 277 280 BaseMetricList::iterator it; … … 295 298 /// @todo (r=dmik) why read lock below? individual elements get modified! 296 299 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. */ 298 304 299 305 BaseMetricList::iterator it; … … 365 371 void PerformanceCollector::registerBaseMetric (pm::BaseMetric *baseMetric) 366 372 { 367 /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure368 /// the object is not uninitialized while you are doing something here373 AutoCaller autoCaller (this); 374 if (!SUCCEEDED (autoCaller.rc())) return; 369 375 370 376 AutoWriteLock alock (this); … … 374 380 void PerformanceCollector::registerMetric (pm::Metric *metric) 375 381 { 376 /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure377 /// the object is not uninitialized while you are doing something here382 AutoCaller autoCaller (this); 383 if (!SUCCEEDED (autoCaller.rc())) return; 378 384 379 385 AutoWriteLock alock (this); … … 383 389 void PerformanceCollector::unregisterBaseMetricsFor (const ComPtr <IUnknown> &aObject) 384 390 { 385 /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure386 /// the object is not uninitialized while you are doing something here391 AutoCaller autoCaller (this); 392 if (!SUCCEEDED (autoCaller.rc())) return; 387 393 388 394 AutoWriteLock alock (this); … … 394 400 void PerformanceCollector::unregisterMetricsFor (const ComPtr <IUnknown> &aObject) 395 401 { 396 /// @todo (r=dmik) better always use AutoCaller unless you are 100% sure397 /// the object is not uninitialized while you are doing something here402 AutoCaller autoCaller (this); 403 if (!SUCCEEDED (autoCaller.rc())) return; 398 404 399 405 AutoWriteLock alock (this); … … 436 442 //////////////////////////////////////////////////////////////////////////////// 437 443 438 PerformanceMetric::PerformanceMetric() : mMetric(0)444 PerformanceMetric::PerformanceMetric() 439 445 { 440 446 } … … 463 469 HRESULT PerformanceMetric::init (pm::Metric *aMetric) 464 470 { 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(); 466 478 return S_OK; 467 479 } … … 476 488 /// AutoReadLock? Is the underlying metric a constant object? 477 489 478 Bstr tmp (mMetric->getName()); 479 tmp.detachTo (aMetricName); 490 m.name.cloneTo (aMetricName); 480 491 return S_OK; 481 492 } … … 483 494 STDMETHODIMP PerformanceMetric::COMGETTER(Object) (IUnknown **anObject) 484 495 { 485 *anObject = mMetric->getObject();496 m.object.queryInterfaceTo(anObject); 486 497 return S_OK; 487 498 } … … 489 500 STDMETHODIMP PerformanceMetric::COMGETTER(Period) (ULONG *aPeriod) 490 501 { 491 *aPeriod = m Metric->getPeriod();502 *aPeriod = m.period; 492 503 return S_OK; 493 504 } … … 495 506 STDMETHODIMP PerformanceMetric::COMGETTER(Count) (ULONG *aCount) 496 507 { 497 *aCount = m Metric->getLength();508 *aCount = m.count; 498 509 return S_OK; 499 510 } … … 501 512 STDMETHODIMP PerformanceMetric::COMGETTER(Unit) (BSTR *aUnit) 502 513 { 503 Bstr tmp (mMetric->getUnit()); 504 tmp.detachTo(aUnit); 514 m.unit.cloneTo(aUnit); 505 515 return S_OK; 506 516 } … … 508 518 STDMETHODIMP PerformanceMetric::COMGETTER(MinimumValue) (LONG *aMinValue) 509 519 { 510 *aMinValue = m Metric->getMinValue();520 *aMinValue = m.min; 511 521 return S_OK; 512 522 } … … 514 524 STDMETHODIMP PerformanceMetric::COMGETTER(MaximumValue) (LONG *aMaxValue) 515 525 { 516 *aMaxValue = m Metric->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 50 50 public IPerformanceMetric 51 51 { 52 private:53 54 struct Data55 {56 /* Constructor. */57 Data() { }58 59 bool operator== (const Data &that) const60 {61 return this == &that;62 }63 };64 65 52 public: 66 53 … … 102 89 private: 103 90 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; 105 106 }; 106 107 -
trunk/src/VBox/Main/testcase/tstAPI.cpp
r10753 r10779 926 926 #endif 927 927 928 #if 0928 #if 1 929 929 do { 930 930 // Get collector … … 1017 1017 } 1018 1018 1019 #if 01019 #if 1 1020 1020 void queryMetrics (ComPtr <IPerformanceCollector> collector, 1021 1021 ComSafeArrayIn (IUnknown *, objects)) … … 1053 1053 Bstr metricUnit(metricUnitBSTR); 1054 1054 Bstr metricName(retNames[i]); 1055 printf(" %ls", metricName.raw());1055 printf("obj(%p) %ls", anObject[0], metricName.raw()); 1056 1056 for (unsigned j = 0; j < retLengths[i]; j++) 1057 1057 {
Note:
See TracChangeset
for help on using the changeset viewer.