summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/agent
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2011-08-15 16:47:56 +0000
committerTed Ross <tross@apache.org>2011-08-15 16:47:56 +0000
commitde19ad9e7157f1b03442f7e1f8136a4f280c0f2f (patch)
treed89370f6b2526c3966216d40b343e50ccde17476 /cpp/src/qpid/agent
parent67663fcc5f0d01f1df1a8cc006ec86725031f10a (diff)
downloadqpid-python-de19ad9e7157f1b03442f7e1f8136a4f280c0f2f.tar.gz
QPID-3423 - Timing and Performance Improvements in QMF Libraries
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1157907 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/agent')
-rw-r--r--cpp/src/qpid/agent/ManagementAgentImpl.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/cpp/src/qpid/agent/ManagementAgentImpl.cpp
index 633401ef5b..f183ff8e0c 100644
--- a/cpp/src/qpid/agent/ManagementAgentImpl.cpp
+++ b/cpp/src/qpid/agent/ManagementAgentImpl.cpp
@@ -1378,13 +1378,26 @@ bool ManagementAgentImpl::ConnectionThread::isSleeping() const
void ManagementAgentImpl::PublishThread::run()
{
- uint16_t totalSleep;
+ uint16_t totalSleep;
+ uint16_t sleepTime;
while (!shutdown) {
agent.periodicProcessing();
totalSleep = 0;
- while (totalSleep++ < agent.getInterval() && !shutdown) {
- ::sleep(1);
+
+ //
+ // Calculate a sleep time that is no greater than 5 seconds and
+ // no less than 1 second.
+ //
+ sleepTime = agent.getInterval();
+ if (sleepTime > 5)
+ sleepTime = 5;
+ else if (sleepTime == 0)
+ sleepTime = 1;
+
+ while (totalSleep < agent.getInterval() && !shutdown) {
+ ::sleep(sleepTime);
+ totalSleep += sleepTime;
}
}
}