summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/DtxManager.cpp
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2012-12-21 17:04:33 +0000
committerAndrew Stitcher <astitcher@apache.org>2012-12-21 17:04:33 +0000
commitf5431bb215c107c1967842cfeb6814cfd3a866a9 (patch)
treecb7b17c8153b84e1c1db6c0331dcc51a1eb22cb5 /cpp/src/qpid/broker/DtxManager.cpp
parentfd54c5f98193aa0a1b2064a13cec094d1be9dfe3 (diff)
downloadqpid-python-f5431bb215c107c1967842cfeb6814cfd3a866a9.tar.gz
NO-JIRA: Removed Timer.h out of the chain of header files included by Broker.h
(since that is widely included) to avoid unnecessary recompilation git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1425037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/DtxManager.cpp')
-rw-r--r--cpp/src/qpid/broker/DtxManager.cpp41
1 files changed, 28 insertions, 13 deletions
diff --git a/cpp/src/qpid/broker/DtxManager.cpp b/cpp/src/qpid/broker/DtxManager.cpp
index d482c2c327..5233e07b2b 100644
--- a/cpp/src/qpid/broker/DtxManager.cpp
+++ b/cpp/src/qpid/broker/DtxManager.cpp
@@ -27,6 +27,9 @@
#include "qpid/ptr_map.h"
#include <boost/format.hpp>
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
+
#include <iostream>
using boost::intrusive_ptr;
@@ -35,6 +38,30 @@ using qpid::ptr_map_ptr;
using namespace qpid::broker;
using namespace qpid::framing;
+namespace {
+ typedef boost::function0<void> FireFunction;
+ struct DtxCleanup : public qpid::sys::TimerTask
+ {
+ FireFunction fireFunction;
+
+ DtxCleanup(uint32_t timeout, FireFunction f);
+ void fire();
+ };
+
+ DtxCleanup::DtxCleanup(uint32_t _timeout, FireFunction f)
+ : TimerTask(qpid::sys::Duration(_timeout * qpid::sys::TIME_SEC),"DtxCleanup"), fireFunction(f){}
+
+ void DtxCleanup::fire()
+ {
+ try {
+ fireFunction();
+ } catch (qpid::ConnectionException& /*e*/) {
+ //assume it was explicitly cleaned up after a call to prepare, commit or rollback
+ }
+ }
+
+}
+
DtxManager::DtxManager(qpid::sys::Timer& t) : store(0), timer(&t) {}
DtxManager::~DtxManager() {}
@@ -156,19 +183,7 @@ void DtxManager::timedout(const std::string& xid)
} else {
ptr_map_ptr(i)->timedout();
//TODO: do we want to have a timed task to cleanup, or can we rely on an explicit completion?
- //timer.add(intrusive_ptr<TimerTask>(new DtxCleanup(60*30/*30 mins*/, *this, xid)));
- }
-}
-
-DtxManager::DtxCleanup::DtxCleanup(uint32_t _timeout, DtxManager& _mgr, const std::string& _xid)
- : TimerTask(qpid::sys::Duration(_timeout * qpid::sys::TIME_SEC),"DtxCleanup"), mgr(_mgr), xid(_xid) {}
-
-void DtxManager::DtxCleanup::fire()
-{
- try {
- mgr.remove(xid);
- } catch (ConnectionException& /*e*/) {
- //assume it was explicitly cleaned up after a call to prepare, commit or rollback
+ //timer->add(new DtxCleanup(60*30/*30 mins*/, boost::bind(&DtxManager::remove, this, xid)));
}
}