summaryrefslogtreecommitdiff
path: root/cpp/managementgen/templates/Class.cpp
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2008-06-30 19:00:49 +0000
committerTed Ross <tross@apache.org>2008-06-30 19:00:49 +0000
commit5a848a6a699d5ab8de93a646a44614378e56871f (patch)
treee2a15b5ad2dd1a30e206601dc8f6902ea875f2e7 /cpp/managementgen/templates/Class.cpp
parent258cccda74ffaa478366bfacda07e61bd88b20ec (diff)
downloadqpid-python-5a848a6a699d5ab8de93a646a44614378e56871f.tar.gz
QPID-1160 - Per-thread counters in management API to avoid locking
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@672864 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/managementgen/templates/Class.cpp')
-rw-r--r--cpp/managementgen/templates/Class.cpp56
1 files changed, 51 insertions, 5 deletions
diff --git a/cpp/managementgen/templates/Class.cpp b/cpp/managementgen/templates/Class.cpp
index 0fbb78b7f1..1ea1da5090 100644
--- a/cpp/managementgen/templates/Class.cpp
+++ b/cpp/managementgen/templates/Class.cpp
@@ -23,6 +23,7 @@
#include "qpid/log/Statement.h"
#include "qpid/framing/FieldTable.h"
#include "qpid/management/Manageable.h"
+#include "qpid/management/ManagementAgent.h"
#include "/*MGEN:Class.NameCap*/.h"
/*MGEN:Class.MethodArgIncludes*/
@@ -36,15 +37,28 @@ string /*MGEN:Class.NameCap*/::className = string ("/*MGEN:Class.NameLower*/
uint8_t /*MGEN:Class.NameCap*/::md5Sum[16] =
{/*MGEN:Class.SchemaMD5*/};
-/*MGEN:Class.NameCap*/::/*MGEN:Class.NameCap*/ (Manageable* _core/*MGEN:Class.ParentArg*//*MGEN:Class.ConstructorArgs*/) :
- ManagementObject(_core)
- /*MGEN:Class.ConstructorInits*/
+/*MGEN:Class.NameCap*/::/*MGEN:Class.NameCap*/ (ManagementAgent* _agent, Manageable* _core/*MGEN:Class.ParentArg*//*MGEN:Class.ConstructorArgs*/) :
+ ManagementObject(_agent, _core)/*MGEN:Class.ConstructorInits*/
{
/*MGEN:Class.ParentRefAssignment*/
/*MGEN:Class.InitializeElements*/
+/*MGEN:IF(Class.ExistPerThreadStats)*/
+ maxThreads = agent->getMaxThreads();
+ perThreadStatsArray = new struct PerThreadStats*[maxThreads];
+ for (int idx = 0; idx < maxThreads; idx++)
+ perThreadStatsArray[idx] = 0;
+/*MGEN:ENDIF*/
}
-/*MGEN:Class.NameCap*/::~/*MGEN:Class.NameCap*/ () {}
+/*MGEN:Class.NameCap*/::~/*MGEN:Class.NameCap*/ ()
+{
+/*MGEN:IF(Class.ExistPerThreadStats)*/
+ for (int idx = 0; idx < maxThreads; idx++)
+ if (perThreadStatsArray[idx] != 0)
+ delete perThreadStatsArray[idx];
+ delete perThreadStatsArray;
+/*MGEN:ENDIF*/
+}
namespace {
const string NAME("name");
@@ -85,6 +99,19 @@ void /*MGEN:Class.NameCap*/::writeSchema (Buffer& buf)
/*MGEN:Class.EventSchema*/
}
+/*MGEN:IF(Class.ExistPerThreadStats)*/
+void /*MGEN:Class.NameCap*/::aggregatePerThreadStats(struct PerThreadStats* totals)
+{
+/*MGEN:Class.InitializeTotalPerThreadStats*/
+ for (int idx = 0; idx < maxThreads; idx++) {
+ struct PerThreadStats* threadStats = perThreadStatsArray[idx];
+ if (threadStats != 0) {
+/*MGEN:Class.AggregatePerThreadStats*/
+ }
+ }
+}
+/*MGEN:ENDIF*/
+
void /*MGEN:Class.NameCap*/::writeProperties (Buffer& buf)
{
sys::Mutex::ScopedLock mutex(accessLock);
@@ -98,14 +125,33 @@ void /*MGEN:Class.NameCap*/::writeStatistics (Buffer& buf, bool skipHeaders)
{
sys::Mutex::ScopedLock mutex(accessLock);
instChanged = false;
+/*MGEN:IF(Class.ExistPerThreadAssign)*/
+ for (int idx = 0; idx < maxThreads; idx++) {
+ struct PerThreadStats* threadStats = perThreadStatsArray[idx];
+ if (threadStats != 0) {
+/*MGEN:Class.PerThreadAssign*/
+ }
+ }
+/*MGEN:ENDIF*/
+/*MGEN:IF(Class.ExistPerThreadStats)*/
+ struct PerThreadStats totals;
+ aggregatePerThreadStats(&totals);
+/*MGEN:ENDIF*/
/*MGEN:Class.Assign*/
-
if (!skipHeaders)
writeTimestamps (buf);
/*MGEN:Class.WriteInst*/
// Maintenance of hi-lo statistics
/*MGEN:Class.HiLoStatResets*/
+/*MGEN:IF(Class.ExistPerThreadResets)*/
+ for (int idx = 0; idx < maxThreads; idx++) {
+ struct PerThreadStats* threadStats = perThreadStatsArray[idx];
+ if (threadStats != 0) {
+/*MGEN:Class.PerThreadHiLoStatResets*/
+ }
+ }
+/*MGEN:ENDIF*/
}
void /*MGEN:Class.NameCap*/::doMethod (/*MGEN:Class.DoMethodArgs*/)