summaryrefslogtreecommitdiffstats
path: root/comphelper
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-06-29 15:03:23 +0300
committerTor Lillqvist <tml@collabora.com>2021-07-05 10:54:32 +0200
commitc8cbf7b9d145c7347c6f64bf3b98b232610949e6 (patch)
treed784e89e4af2b66e6d8a64a34cda1453a902e683 /comphelper
parentlok: fix incorrect multi-view table selection updates (diff)
downloadcore-c8cbf7b9d145c7347c6f64bf3b98b232610949e6.tar.gz
core-c8cbf7b9d145c7347c6f64bf3b98b232610949e6.zip
Enable flushing accumulated Trace Events when their number reaches a limit
Change-Id: I99ecf56b0faa5c444dbe9e22b8cce035f240c35c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118119 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/traceevent.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index 793fea6cdb0e..c379bbb97f7e 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -24,6 +24,10 @@ std::atomic<bool> TraceEvent::s_bRecording = (getenv("TRACE_EVENT_RECORDING") !=
#else
std::atomic<bool> TraceEvent::s_bRecording = false;
#endif
+
+std::size_t TraceEvent::s_nBufferSize = 0;
+void (*TraceEvent::s_pBufferFullCallback)() = nullptr;
+
int AsyncEvent::s_nIdCounter = 0;
int ProfileZone::s_nNesting = 0;
@@ -38,6 +42,12 @@ void TraceEvent::addRecording(const OUString& sObject)
osl::MutexGuard aGuard(g_aMutex);
g_aRecording.emplace_back(sObject);
+
+ if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize)
+ {
+ if (s_pBufferFullCallback != nullptr)
+ (*s_pBufferFullCallback)();
+ }
}
void TraceEvent::addInstantEvent(const char* sName, const std::map<OUString, OUString>& args)
@@ -72,6 +82,12 @@ void TraceEvent::startRecording()
void TraceEvent::stopRecording() { s_bRecording = false; }
+void TraceEvent::setBufferSizeAndCallback(std::size_t bufferSize, void (*bufferFullCallback)())
+{
+ s_nBufferSize = bufferSize;
+ s_pBufferFullCallback = bufferFullCallback;
+}
+
std::vector<OUString> TraceEvent::getEventVectorAndClear()
{
bool bRecording;