Changeset 60977 in vbox for trunk/src/VBox/Main/src-all
- Timestamp:
- May 13, 2016 1:06:26 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-all/VirtualBoxBase.cpp
r58132 r60977 7 7 8 8 /* 9 * Copyright (C) 2006-201 4Oracle Corporation9 * Copyright (C) 2006-2016 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 48 48 //////////////////////////////////////////////////////////////////////////////// 49 49 50 VirtualBoxBase::VirtualBoxBase() : mState(this) 50 CLASSFACTORY_STAT g_aClassFactoryStats[CLASSFACTORYSTATS_MAX] = 51 { 52 { "--- totals ---", 0 }, 53 { NULL, 0 } 54 }; 55 56 RWLockHandle *g_pClassFactoryStatsLock = NULL; 57 58 59 VirtualBoxBase::VirtualBoxBase() : 60 mState(this), 61 iFactoryStat(~0U) 51 62 { 52 63 mObjectLock = NULL; 64 65 if (!g_pClassFactoryStatsLock) 66 { 67 RWLockHandle *lock = new RWLockHandle(LOCKCLASS_OBJECTSTATE); 68 if (!ASMAtomicCmpXchgPtr(&g_pClassFactoryStatsLock, lock, NULL)) 69 delete lock; 70 } 71 Assert(g_pClassFactoryStatsLock); 53 72 } 54 73 55 74 VirtualBoxBase::~VirtualBoxBase() 56 75 { 76 Assert(iFactoryStat == ~0U); 57 77 if (mObjectLock) 58 78 delete mObjectLock; 79 } 80 81 HRESULT VirtualBoxBase::BaseFinalConstruct() 82 { 83 Assert(iFactoryStat == ~0U); 84 if (g_pClassFactoryStatsLock) 85 { 86 AutoWriteLock alock(g_pClassFactoryStatsLock COMMA_LOCKVAL_SRC_POS); 87 g_aClassFactoryStats[0].current++; 88 g_aClassFactoryStats[0].overall++; 89 const char *pszName = getComponentName(); 90 uint32_t i = 1; 91 while (i < CLASSFACTORYSTATS_MAX && g_aClassFactoryStats[i].psz) 92 { 93 if (g_aClassFactoryStats[i].psz == pszName) 94 break; 95 i++; 96 } 97 if (i < CLASSFACTORYSTATS_MAX) 98 { 99 if (!g_aClassFactoryStats[i].psz) 100 { 101 g_aClassFactoryStats[i].psz = pszName; 102 g_aClassFactoryStats[i].current = 0; 103 g_aClassFactoryStats[i].overall = 0; 104 } 105 iFactoryStat = i; 106 g_aClassFactoryStats[i].current++; 107 g_aClassFactoryStats[i].overall++; 108 } 109 else 110 AssertMsg(i < CLASSFACTORYSTATS_MAX, ("%u exhausts size of factory housekeeping array\n", i)); 111 } 112 else 113 Assert(g_pClassFactoryStatsLock); 114 115 #ifdef RT_OS_WINDOWS 116 return CoCreateFreeThreadedMarshaler(this, //GetControllingUnknown(), 117 m_pUnkMarshaler.asOutParam()); 118 #else 119 return S_OK; 120 #endif 121 } 122 123 void VirtualBoxBase::BaseFinalRelease() 124 { 125 if (g_pClassFactoryStatsLock) 126 { 127 AutoWriteLock alock(g_pClassFactoryStatsLock COMMA_LOCKVAL_SRC_POS); 128 g_aClassFactoryStats[0].current--; 129 const char *pszName = getComponentName(); 130 if (iFactoryStat < CLASSFACTORYSTATS_MAX) 131 { 132 if (g_aClassFactoryStats[iFactoryStat].psz == pszName) 133 { 134 g_aClassFactoryStats[iFactoryStat].current--; 135 iFactoryStat = ~0U; 136 } 137 else 138 AssertMsgFailed(("could not find factory housekeeping array entry for %s (index %u contains %s)\n", pszName, iFactoryStat, g_aClassFactoryStats[iFactoryStat].psz)); 139 } 140 else 141 AssertMsgFailed(("factory housekeeping array corruption, index %u is too large\n", iFactoryStat)); 142 } 143 else 144 Assert(g_pClassFactoryStatsLock); 145 146 #ifdef RT_OS_WINDOWS 147 m_pUnkMarshaler.setNull(); 148 #endif 149 } 150 151 void APIDumpComponentFactoryStats() 152 { 153 if (g_pClassFactoryStatsLock) 154 { 155 AutoReadLock alock(g_pClassFactoryStatsLock COMMA_LOCKVAL_SRC_POS); 156 for (uint32_t i = 0; i < CLASSFACTORYSTATS_MAX && g_aClassFactoryStats[i].psz; i++) 157 LogRel(("CFS: component %-30s current %-10u total %-10u\n", 158 g_aClassFactoryStats[i].psz, g_aClassFactoryStats[i].current, 159 g_aClassFactoryStats[i].overall)); 160 } 161 else 162 Assert(g_pClassFactoryStatsLock); 59 163 } 60 164
Note:
See TracChangeset
for help on using the changeset viewer.