summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2009-08-07 01:54:06 +0000
committerAndrew Stitcher <astitcher@apache.org>2009-08-07 01:54:06 +0000
commitd75b1f34c306b769daf7aadd9431e7c02e02a34a (patch)
treee9e3298ef1ec77f06a19e764ee8a0c53c680453d /qpid/cpp
parent5b56e3b8e41cba9314808ec1bd0d85cd771ef3f3 (diff)
downloadqpid-python-d75b1f34c306b769daf7aadd9431e7c02e02a34a.tar.gz
Change LinkRegistry to cancel its TimerTask in its destructor
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@801860 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/src/qpid/broker/LinkRegistry.cpp11
-rw-r--r--qpid/cpp/src/qpid/broker/LinkRegistry.h4
2 files changed, 13 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/broker/LinkRegistry.cpp b/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
index c70392eb23..fc7b88a04a 100644
--- a/qpid/cpp/src/qpid/broker/LinkRegistry.cpp
+++ b/qpid/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/qpid/cpp/src/qpid/broker/LinkRegistry.h b/qpid/cpp/src/qpid/broker/LinkRegistry.h
index d1a4201c82..09a89298b6 100644
--- a/qpid/cpp/src/qpid/broker/LinkRegistry.h
+++ b/qpid/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,