summaryrefslogtreecommitdiff
path: root/comphelper/source/misc
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-06-29 15:03:23 +0300
committerTor Lillqvist <tml@collabora.com>2021-06-29 16:01:53 +0200
commit09e89e7282a032c4cb944a66c0ddf199b9aa4a0b (patch)
tree02b0dd72e8e64f3637babcf4857a39351399176b /comphelper/source/misc
parent33680cc4dc3a50081fc0b82fb0abf03c9744b310 (diff)
Enable flushing accumulated Trace Events when their number reaches a limit
Change-Id: I99ecf56b0faa5c444dbe9e22b8cce035f240c35c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118088 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'comphelper/source/misc')
-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;