[Libreoffice-commits] core.git: comphelper/source include/comphelper

Gopi Krishna Menon (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 30 11:08:27 UTC 2021


 comphelper/source/misc/traceevent.cxx |    7 ++++++-
 include/comphelper/profilezone.hxx    |   12 +++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 74f4a1796f94477d459c71d0a0aaa8f4a430e208
Author:     Gopi Krishna Menon <gopi.menon at collabora.com>
AuthorDate: Thu Jul 29 15:21:13 2021 +0530
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Jul 30 13:07:49 2021 +0200

    Fix Nesting Level Bug in ProfileZone
    
    Moves the profile zone global nesting variable into the source from header and makes it threadlocal
    
    Change-Id: I97751f5c532d8e0e36adb7d9d383bd88f752953f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119662
    Tested-by: Jenkins
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index c379bbb97f7e..8b1a9c09427a 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -29,7 +29,8 @@ std::size_t TraceEvent::s_nBufferSize = 0;
 void (*TraceEvent::s_pBufferFullCallback)() = nullptr;
 
 int AsyncEvent::s_nIdCounter = 0;
-int ProfileZone::s_nNesting = 0;
+
+static thread_local int nProfileZoneNesting = 0; // Level of Nested Profile Zones
 
 namespace
 {
@@ -134,6 +135,10 @@ void ProfileZone::addRecording()
                              + OUString::number(osl_getThreadIdentifier(nullptr)) + "},");
 }
 
+int ProfileZone::getNestingLevel() { return nProfileZoneNesting; }
+
+void ProfileZone::setNestingLevel(int nNestingLevel) { nProfileZoneNesting = nNestingLevel; }
+
 } // namespace comphelper
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx
index b96b26baffc1..71f9fa30b6dc 100644
--- a/include/comphelper/profilezone.hxx
+++ b/include/comphelper/profilezone.hxx
@@ -22,13 +22,14 @@ namespace comphelper
 {
 class COMPHELPER_DLLPUBLIC ProfileZone : public NamedEvent
 {
-    static int s_nNesting; // level of nested zones.
-
     long long m_nCreateTime;
     int m_nNesting;
 
     void addRecording();
 
+    static void setNestingLevel(int nNestingLevel);
+    static int getNestingLevel();
+
     ProfileZone(const char* sName, const OUString& sArgs)
         : NamedEvent(sName, sArgs)
         , m_nNesting(-1)
@@ -37,7 +38,8 @@ class COMPHELPER_DLLPUBLIC ProfileZone : public NamedEvent
         {
             m_nCreateTime = getNow();
 
-            m_nNesting = s_nNesting++;
+            m_nNesting = getNestingLevel();
+            setNestingLevel(getNestingLevel() + 1);
         }
         else
             m_nCreateTime = 0;
@@ -65,9 +67,9 @@ public:
     {
         if (m_nCreateTime > 0)
         {
-            s_nNesting--;
+            setNestingLevel(getNestingLevel() - 1);
 
-            if (m_nNesting != s_nNesting)
+            if (m_nNesting != getNestingLevel())
             {
                 SAL_WARN("comphelper.traceevent", "Incorrect ProfileZone nesting for " << m_sName);
             }


More information about the Libreoffice-commits mailing list