summaryrefslogtreecommitdiff
path: root/comphelper/source/misc/traceevent.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/source/misc/traceevent.cxx')
-rw-r--r--comphelper/source/misc/traceevent.cxx21
1 files changed, 11 insertions, 10 deletions
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index 8b1a9c09427a..1296404ebd32 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -10,8 +10,8 @@
#include <sal/config.h>
#include <atomic>
+#include <mutex>
#include <iostream>
-#include <string_view>
#include <comphelper/profilezone.hxx>
#include <comphelper/sequence.hxx>
@@ -35,20 +35,21 @@ static thread_local int nProfileZoneNesting = 0; // Level of Nested Profile Zone
namespace
{
std::vector<OUString> g_aRecording; // recorded data
-osl::Mutex g_aMutex;
+std::mutex g_aMutex;
}
void TraceEvent::addRecording(const OUString& sObject)
{
- osl::MutexGuard aGuard(g_aMutex);
+ bool bEmitCallback;
+ {
+ std::lock_guard aGuard(g_aMutex);
- g_aRecording.emplace_back(sObject);
+ g_aRecording.emplace_back(sObject);
- if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize)
- {
- if (s_pBufferFullCallback != nullptr)
- (*s_pBufferFullCallback)();
+ bEmitCallback = s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize;
}
+ if (bEmitCallback && s_pBufferFullCallback != nullptr)
+ (*s_pBufferFullCallback)();
}
void TraceEvent::addInstantEvent(const char* sName, const std::map<OUString, OUString>& args)
@@ -77,7 +78,7 @@ void TraceEvent::addInstantEvent(const char* sName, const std::map<OUString, OUS
void TraceEvent::startRecording()
{
- osl::MutexGuard aGuard(g_aMutex);
+ std::lock_guard aGuard(g_aMutex);
s_bRecording = true;
}
@@ -94,7 +95,7 @@ std::vector<OUString> TraceEvent::getEventVectorAndClear()
bool bRecording;
std::vector<OUString> aRecording;
{
- osl::MutexGuard aGuard(g_aMutex);
+ std::lock_guard aGuard(g_aMutex);
bRecording = s_bRecording;
stopRecording();
aRecording.swap(g_aRecording);