summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2009-08-07 01:53:50 +0000
committerAndrew Stitcher <astitcher@apache.org>2009-08-07 01:53:50 +0000
commitdb71c1d728864e41d8be7c5c91c0a7e84940284c (patch)
treee36ae760ef5dd1c29ea956dcd70bf9786dbdaa96 /cpp/src
parent038e48fa0110f682806e34e34a22ab75c6f51da9 (diff)
downloadqpid-python-db71c1d728864e41d8be7c5c91c0a7e84940284c.tar.gz
Change LinkRegistry to cancel its TimerTask in its destructor
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@801860 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/broker/LinkRegistry.cpp11
-rw-r--r--cpp/src/qpid/broker/LinkRegistry.h4
2 files changed, 13 insertions, 2 deletions
diff --git a/cpp/src/qpid/broker/LinkRegistry.cpp b/cpp/src/qpid/broker/LinkRegistry.cpp
index c70392eb23..fc7b88a04a 100644
--- a/cpp/src/qpid/broker/LinkRegistry.cpp
+++ b/cpp/src/qpid/broker/LinkRegistry.cpp
@@ -49,10 +49,16 @@ LinkRegistry::LinkRegistry () :
LinkRegistry::LinkRegistry (Broker* _broker) :
broker(_broker), timer(&broker->getTimer()),
+ maintenanceTask(new Periodic(*this)),
parent(0), store(0), passive(false), passiveChanged(false),
realm(broker->getOptions().realm)
{
- timer->add (new Periodic(*this));
+ timer->add(maintenanceTask);
+}
+
+LinkRegistry::~LinkRegistry()
+{
+ maintenanceTask->cancel();
}
LinkRegistry::Periodic::Periodic (LinkRegistry& _links) :
@@ -61,7 +67,8 @@ LinkRegistry::Periodic::Periodic (LinkRegistry& _links) :
void LinkRegistry::Periodic::fire ()
{
links.periodicMaintenance ();
- links.timer->add (new Periodic(links));
+ setupNextFire();
+ links.timer->add (this);
}
void LinkRegistry::periodicMaintenance ()
diff --git a/cpp/src/qpid/broker/LinkRegistry.h b/cpp/src/qpid/broker/LinkRegistry.h
index d1a4201c82..09a89298b6 100644
--- a/cpp/src/qpid/broker/LinkRegistry.h
+++ b/cpp/src/qpid/broker/LinkRegistry.h
@@ -30,6 +30,7 @@
#include "qpid/sys/Timer.h"
#include "qpid/management/Manageable.h"
#include <boost/shared_ptr.hpp>
+#include <boost/intrusive_ptr.hpp>
namespace qpid {
namespace broker {
@@ -63,6 +64,7 @@ namespace broker {
qpid::sys::Mutex lock;
Broker* broker;
sys::Timer* timer;
+ boost::intrusive_ptr<qpid::sys::TimerTask> maintenanceTask;
management::Manageable* parent;
MessageStore* store;
bool passive;
@@ -77,6 +79,8 @@ namespace broker {
public:
LinkRegistry (); // Only used in store tests
LinkRegistry (Broker* _broker);
+ ~LinkRegistry();
+
std::pair<boost::shared_ptr<Link>, bool>
declare(std::string& host,
uint16_t port,