[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - comphelper/source include/comphelper
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 15 10:17:19 UTC 2021
comphelper/source/misc/traceevent.cxx | 16 ++++++++++++++++
include/comphelper/traceevent.hxx | 4 ++++
2 files changed, 20 insertions(+)
New commits:
commit 794b68bb1bbe80717c530530358799c6a4d598c0
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Jun 29 15:03:23 2021 +0300
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 15 12:16:46 2021 +0200
Enable flushing accumulated Trace Events when their number reaches a limit
Change-Id: I99ecf56b0faa5c444dbe9e22b8cce035f240c35c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118119
Reviewed-by: Tor Lillqvist <tml at collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118932
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index 5f0ddcc18d39..4fc4410615b4 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;
diff --git a/include/comphelper/traceevent.hxx b/include/comphelper/traceevent.hxx
index 7d6993dc79c9..f6b512fdebd5 100644
--- a/include/comphelper/traceevent.hxx
+++ b/include/comphelper/traceevent.hxx
@@ -43,6 +43,9 @@ private:
return -1;
}
+ static std::size_t s_nBufferSize;
+ static void (*s_pBufferFullCallback)();
+
protected:
static std::atomic<bool> s_bRecording; // true during recording
@@ -99,6 +102,7 @@ public:
static void startRecording();
static void stopRecording();
+ static void setBufferSizeAndCallback(std::size_t bufferSize, void (*bufferFullCallback)());
static std::vector<OUString> getEventVectorAndClear();
More information about the Libreoffice-commits
mailing list