@@ -52,10 +52,10 @@ struct CCallStackStatsGatherer_FunctionTable_t {
5252// translator function
5353class CCallStackStatsGatherer_Standardized_t {
5454 public:
55- CCallStackStatsGatherer_Standardized_t (void ){};
55+ CCallStackStatsGatherer_Standardized_t (void ) {};
5656 CCallStackStatsGatherer_Standardized_t (
5757 void *pThis, const CCallStackStatsGatherer_FunctionTable_t &FnTable)
58- : pGatherer(pThis), pFunctionTable(&FnTable){};
58+ : pGatherer(pThis), pFunctionTable(&FnTable) {};
5959
6060 // go ahead and create some helper functions that are likely to be used by
6161 // helper code
@@ -85,7 +85,7 @@ class CCallStackStatsGatherer_StructAccessor_Base {
8585 public:
8686 CCallStackStatsGatherer_StructAccessor_Base (
8787 const CCallStackStatsGatherer_Standardized_t &Gatherer, int iEntryIndex)
88- : m_Gatherer(Gatherer), m_iEntryIndex(iEntryIndex){};
88+ : m_Gatherer(Gatherer), m_iEntryIndex(iEntryIndex) {};
8989
9090 protected:
9191 uint32
@@ -108,7 +108,7 @@ class CCallStackStatsGatherer_StatMutexPool {
108108 void LockEntry (uint32 iEntryIndex, bool bLock) {
109109#if defined(ENABLE_STACK_STATS_GATHERING)
110110 static_assert ((SHAREDENTRYMUTEXES & (SHAREDENTRYMUTEXES - 1 )) ==
111- 0 ); // must be a power of 2
111+ 0 ); // must be a power of 2
112112
113113 if (bLock) {
114114 m_IndividualEntryMutexes[iEntryIndex & (SHAREDENTRYMUTEXES - 1 )].Lock ();
@@ -126,10 +126,11 @@ class CCallStackStatsGatherer_StatMutexPool {
126126// tracking. CAPTUREDCALLSTACKLENGTH - The maximum length of your stack trace
127127// that we'll use to distinguish entries STACKACQUISITIONFUNCTION - The function
128128// to use to gather the current call stack. GetCallStack() is safe,
129- // GetCallStack_Fast() is faster, but has special requirements STATMUTEXHANDLER -
130- // If you want automatic mutex management for your individual entries, supply a
131- // handler here. You'll need to not only call GetEntry(), but lock/unlock the
132- // entry while accessing it. TEMPLATIZEDMEMORYALLOCATOR - We'll need to allocate
129+ // GetCallStack_Fast() is faster, but has special requirements STATMUTEXHANDLER
130+ // - If you want automatic mutex management for your individual entries, supply
131+ // a handler here. You'll need to
132+ // not only call GetEntry(), but lock/unlock the
133+ // entry while accessing it. TEMPLATIZEDMEMORYALLOCATOR - We'll need to allocate
133134// memory, supply an allocator if you want to manage that
134135template <class STATSTRUCT , size_t CAPTUREDCALLSTACKLENGTH,
135136 FN_GetCallStack STACKACQUISITIONFUNCTION = GetCallStack,
@@ -148,9 +149,9 @@ class CCallStackStatsGatherer : public STATMUTEXHANDLER {
148149 CCallStackStatsGatherer_StructAccessor_Base<STATSTRUCT> GetEntry (
149150 void *const
150151 CallStack[CAPTUREDCALLSTACKLENGTH]); // get the entry using some
151- // callstack grabbed a while ago.
152- // Assumes ALL invalid entries
153- // have been nullified
152+ // callstack grabbed a while
153+ // ago. Assumes ALL invalid
154+ // entries have been nullified
154155 CCallStackStatsGatherer_StructAccessor_Base<STATSTRUCT> GetEntry (
155156 void *const CallStack[CAPTUREDCALLSTACKLENGTH],
156157 uint32 iValidEntries); // same as above, but does the work of nullifying
@@ -266,8 +267,7 @@ class CCallStackStatsGatherer : public STATMUTEXHANDLER {
266267
267268 void KeepSubTree (CCallStackStatsGatherer_Standardized_t &SubTree) {
268269 AUTO_LOCK_FM (m_SubTreeMutex);
269- for (typename StoredSubTreeVector_t::iterator treeIter =
270- m_StoredSubTrees.begin ();
270+ for (auto treeIter = m_StoredSubTrees.begin ();
271271 treeIter != m_StoredSubTrees.end (); ++treeIter) {
272272 if (SubTree.pGatherer == treeIter->pGatherer ) return ;
273273 }
@@ -309,7 +309,8 @@ class CCallStackStatsGatherer : public STATMUTEXHANDLER {
309309 // szTemp ), "\n\t" );
310310
311311 // Warning( "Attempting to link
312- // trees:\n=======================ONE=======================\n\t%s\n", szTemp
312+ // trees:\n=======================ONE=======================\n\t%s\n",
313+ // szTemp
313314 // ); TranslateStackInfo( treeIter->Stack, CAPTUREDCALLSTACKLENGTH, szTemp,
314315 // sizeof( szTemp ), "\n\t" ); Warning(
315316 // "=======================TWO=======================\n\t%s\n", szTemp );
@@ -324,7 +325,8 @@ class CCallStackStatsGatherer : public STATMUTEXHANDLER {
324325 if (CallStackIn[i] == pMatchAddress) {
325326 // TranslateStackInfo( CallStackIn, i, szTemp, sizeof( szTemp ), "\n\t"
326327 // ); Warning(
327- // "======================MATCH======================\n\t%s\n", szTemp );
328+ // "======================MATCH======================\n\t%s\n", szTemp
329+ // );
328330
329331 CallStackOut[i] =
330332 treeIter->tree
@@ -341,7 +343,7 @@ class CCallStackStatsGatherer : public STATMUTEXHANDLER {
341343 }
342344
343345 struct StatIndex_t {
344- StatIndex_t (void ) : m_Index((unsigned int )-1 ){};
346+ StatIndex_t (void ) : m_Index((unsigned int )-1 ) {};
345347 unsigned int m_Index;
346348 };
347349
@@ -384,7 +386,7 @@ class CCallStackStatsGatherer : public STATMUTEXHANDLER {
384386 // access the same index simultaneously
385387 CThreadRWLock m_StatEntryLock;
386388
387- #else // #if defined( ENABLE_STACK_STATS_GATHERING )
389+ #else // #if defined( ENABLE_STACK_STATS_GATHERING )
388390
389391 STATSTRUCT m_SingleEntry; // the class is disabled, we'll always return this
390392 // same struct
@@ -395,7 +397,7 @@ class CCallStackStatsGatherer : public STATMUTEXHANDLER {
395397 return 0 ;
396398 }
397399
398- #endif // #if defined( ENABLE_STACK_STATS_GATHERING )
400+ #endif // #if defined( ENABLE_STACK_STATS_GATHERING )
399401};
400402
401403template <class STATSTRUCT , size_t CAPTUREDCALLSTACKLENGTH,
@@ -477,13 +479,13 @@ PLATFORM_INTERFACE size_t _CCallStackStatsGatherer_Write_FieldDescriptions(
477479 iWroteBytes += _CCallStackStatsGatherer_Write_FieldDescriptions( \
478480 GetStatStructFieldDescriptions (), pDescribeWriteBuffer + iWroteBytes, \
479481 iDescribeMaxLength - iWroteBytes);
480- // #define WRITE_STATSTRUCT_FIELDMERGESCRIPT( scriptMergeLanguage ) iWroteBytes
482+ // #define WRITE_STATSTRUCT_FIELDMERGESCRIPT( scriptMergeLanguage ) iWroteBytes
481483// += _CCallStackStatsGatherer_Write_FieldMergeScript(
482- // GetStatStructFieldDescriptions(),
483- // CallStackStatStructDescFuncs::scriptMergeLanguage, pDescribeWriteBuffer +
484- // iWroteBytes, iDescribeMaxLength - iWroteBytes );
484+ // GetStatStructFieldDescriptions(),
485+ // CallStackStatStructDescFuncs::scriptMergeLanguage, pDescribeWriteBuffer +
486+ // iWroteBytes, iDescribeMaxLength - iWroteBytes );
485487
486- #else // #if defined( ENABLE_STACK_STATS_GATHERING )
488+ #else // #if defined( ENABLE_STACK_STATS_GATHERING )
487489
488490#define DECLARE_CALLSTACKSTATSTRUCT ()
489491#define BEGIN_STATSTRUCTDESCRIPTION (className )
@@ -495,9 +497,9 @@ PLATFORM_INTERFACE size_t _CCallStackStatsGatherer_Write_FieldDescriptions(
495497#define END_STATSTRUCTFIELDDESCRIPTION ()
496498
497499#define WRITE_STATSTRUCT_FIELDDESCRIPTION ()
498- // #define WRITE_STATSTRUCT_FIELDMERGESCRIPT( scriptMergeLanguage )
500+ // #define WRITE_STATSTRUCT_FIELDMERGESCRIPT( scriptMergeLanguage )
499501
500- #endif // #if defined( ENABLE_STACK_STATS_GATHERING )
502+ #endif // #if defined( ENABLE_STACK_STATS_GATHERING )
501503
502504template <class STATSTRUCT , size_t CAPTUREDCALLSTACKLENGTH,
503505 FN_GetCallStack STACKACQUISITIONFUNCTION, typename STATMUTEXHANDLER,
@@ -700,19 +702,18 @@ const CCallStackStatsGatherer_FunctionTable_t &CCallStackStatsGatherer<
700702 STATSTRUCT, CAPTUREDCALLSTACKLENGTH, STACKACQUISITIONFUNCTION,
701703 STATMUTEXHANDLER, TEMPLATIZEDMEMORYALLOCATOR>::GetFunctionTable(void ) {
702704 static CCallStackStatsGatherer_FunctionTable_t retVal = {
703- GetDumpInfo,
704- PushSubTree,
705- PopSubTree,
705+ GetDumpInfo,
706+ PushSubTree,
707+ PopSubTree,
706708#if defined(ENABLE_STACK_STATS_GATHERING)
707- STATSTRUCT::DescribeCallStackStatStruct,
709+ STATSTRUCT::DescribeCallStackStatStruct,
708710#else
709- NULL_DescribeCallStackStatStruct,
711+ NULL_DescribeCallStackStatStruct,
710712#endif
711- SyncMutexes,
712- GetEntry,
713- ApplyTreeAccessLock,
714- LockEntry
715- };
713+ SyncMutexes,
714+ GetEntry,
715+ ApplyTreeAccessLock,
716+ LockEntry};
716717
717718 return retVal;
718719}
@@ -773,9 +774,8 @@ void CCallStackStatsGatherer<STATSTRUCT, CAPTUREDCALLSTACKLENGTH,
773774 pushVal.Stack [i] = NULL ;
774775 }
775776
776- pParentCast->m_SubTreeMutex . Lock ( );
777+ AUTO_LOCK ( pParentCast->m_SubTreeMutex );
777778 pParentCast->m_PushedSubTrees .push_back (pushVal);
778- pParentCast->m_SubTreeMutex .Unlock ();
779779#endif
780780}
781781
@@ -801,11 +801,12 @@ void CCallStackStatsGatherer<
801801 STATMUTEXHANDLER, TEMPLATIZEDMEMORYALLOCATOR>::PopSubTree(void *pParent) {
802802#if defined(ENABLE_STACK_STATS_GATHERING)
803803 ThisCast *pParentCast = (ThisCast *)pParent;
804- pParentCast-> m_SubTreeMutex . Lock ();
804+
805805 unsigned long iThreadID = ThreadGetCurrentId ();
806806
807- for (typename PushedSubTreeVector_t::reverse_iterator treeIter =
808- pParentCast->m_PushedSubTrees .rbegin ();
807+ AUTO_LOCK (pParentCast->m_SubTreeMutex );
808+
809+ for (auto treeIter = pParentCast->m_PushedSubTrees .rbegin ();
809810 treeIter != pParentCast->m_PushedSubTrees .rend (); ++treeIter) {
810811 if (treeIter->iThreadID == iThreadID) {
811812 ++treeIter; // [24.4.1/1] &*(reverse_iterator(i)) == &*(i - 1)
@@ -814,8 +815,6 @@ void CCallStackStatsGatherer<
814815 break ;
815816 }
816817 }
817-
818- pParentCast->m_SubTreeMutex .Unlock ();
819818#endif
820819}
821820
@@ -833,14 +832,12 @@ void CCallStackStatsGatherer<STATSTRUCT, CAPTUREDCALLSTACKLENGTH,
833832 pParentCast->m_IndexMapMutex .Lock ();
834833 pParentCast->m_SubTreeMutex .Lock ();
835834
836- for (typename StoredSubTreeVector_t::iterator treeIter =
837- pParentCast->m_StoredSubTrees .begin ();
835+ for (auto treeIter = pParentCast->m_StoredSubTrees .begin ();
838836 treeIter != pParentCast->m_StoredSubTrees .end (); ++treeIter) {
839837 treeIter->pFunctionTable ->pfn_SyncMutexes (treeIter->pGatherer , true );
840838 }
841839 } else {
842- for (typename StoredSubTreeVector_t::iterator treeIter =
843- pParentCast->m_StoredSubTrees .begin ();
840+ for (auto treeIter = pParentCast->m_StoredSubTrees .begin ();
844841 treeIter != pParentCast->m_StoredSubTrees .end (); ++treeIter) {
845842 treeIter->pFunctionTable ->pfn_SyncMutexes (treeIter->pGatherer , false );
846843 }
@@ -906,15 +903,16 @@ void CCallStackStatsGatherer<STATSTRUCT, CAPTUREDCALLSTACKLENGTH,
906903 TEMPLATIZEDMEMORYALLOCATOR>::Reset(void ) {
907904#if defined(ENABLE_STACK_STATS_GATHERING)
908905 m_StatEntryLock.LockForWrite ();
909- m_IndexMapMutex.Lock ();
910- m_SubTreeMutex.Lock ();
911906
912- m_StatEntries.clear ();
913- m_IndexMap.clear ();
914- m_StoredSubTrees.clear ();
907+ {
908+ AUTO_LOCK (m_IndexMapMutex);
909+ AUTO_LOCK (m_SubTreeMutex);
910+
911+ m_StatEntries.clear ();
912+ m_IndexMap.clear ();
913+ m_StoredSubTrees.clear ();
914+ }
915915
916- m_SubTreeMutex.Unlock ();
917- m_IndexMapMutex.Unlock ();
918916 m_StatEntryLock.UnlockWrite ();
919917#endif
920918}
@@ -953,20 +951,20 @@ class PLATFORM_CLASS CallStackStatStructDescFuncs {
953951
954952#if 0 // embedded script handling not ready yet
955953 // this is expected to write a piece of script code into the body of a
956- // function that will merge two values of this type The function will have
957- // two parameters, "mergeTo", and "mergeFrom". Both are tables with your
958- // field defined by name So, an example to merge an integer count defined
959- // as "foo" in the stack struct would look like this "mergeTo.foo +=
960- // mergeFrom.foo\n"
954+ // function that will merge two values of this type The function will
955+ // have two parameters, "mergeTo", and "mergeFrom". Both are tables with
956+ // your field defined by name So, an example to merge an integer count
957+ // defined as "foo" in the stack struct would look like this "mergeTo.foo
958+ // += mergeFrom.foo\n"
961959 virtual size_t DescribeMergeOperation( MergeScript_Language scriptLanguage, uint8 *pDescribeWriteBuffer, size_t iDescribeMaxLength ) = 0;
962960#endif
963961
964962 // reserve your description field versions here to avoid stomping others
965963 enum DescribeFieldVersions_t {
966964 DFV_BasicStatStructFieldTypes_t, // Format: 1 byte
967- // BasicStatStructFieldTypes_t type, 4 byte
968- // field offset, null terminated string
969- // field name
965+ // BasicStatStructFieldTypes_t type, 4
966+ // byte field offset, null terminated
967+ // string field name
970968 };
971969
972970 const char *m_szFieldName;
@@ -1033,7 +1031,7 @@ class PLATFORM_CLASS BasicStatStructFieldDesc
10331031 public:
10341032 BasicStatStructFieldDesc (BasicStatStructFieldTypes_t type,
10351033 BasicStatStructFieldCombineMethods_t combineMethod)
1036- : m_Type(type), m_Combine(combineMethod){};
1034+ : m_Type(type), m_Combine(combineMethod) {};
10371035 size_t DescribeField (uint8 *pDescribeWriteBuffer, size_t iDescribeMaxLength);
10381036#if 0 // embedded script handling not ready yet
10391037 size_t DescribeMergeOperation( MergeScript_Language scriptLanguage, uint8 *pDescribeWriteBuffer, size_t iDescribeMaxLength );
0 commit comments