From 9c73ef7a5ac10acd6a50d5d52bd721fc2faa5919 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Thu, 28 Feb 2013 16:14:30 +0000 Subject: Update from trunk r1375509 through r1450773 git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1451244 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/DtxManager.cpp | 41 ++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'cpp/src/qpid/broker/DtxManager.cpp') diff --git a/cpp/src/qpid/broker/DtxManager.cpp b/cpp/src/qpid/broker/DtxManager.cpp index c55771c4e6..3b23ea2900 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 +#include +#include + #include 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 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(qpid::sys::Timer& t) : asyncTxnStore(0), timer(&t) {} @@ -158,19 +185,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(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))); } } -- cgit v1.2.1