diff options
author | Alan Conway <aconway@apache.org> | 2009-05-01 19:59:57 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-05-01 19:59:57 +0000 |
commit | 91e3b712f13fcbf3834ae547bd05254738dfed8e (patch) | |
tree | 36265cf107759f8fe309f02a3a3dba84dfb4bef2 /cpp/src | |
parent | f3cec6986a366d133a08647279a38393a9769718 (diff) | |
download | qpid-python-91e3b712f13fcbf3834ae547bd05254738dfed8e.tar.gz |
Replace std::list with std::deque for SemanticState::unacked - more efficient, improves latency.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@770802 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/broker/DeliveryRecord.cpp | 4 | ||||
-rw-r--r-- | cpp/src/qpid/broker/DeliveryRecord.h | 18 | ||||
-rw-r--r-- | cpp/src/qpid/broker/DtxAck.cpp | 4 | ||||
-rw-r--r-- | cpp/src/qpid/broker/DtxAck.h | 4 | ||||
-rw-r--r-- | cpp/src/qpid/broker/SemanticState.cpp | 8 | ||||
-rw-r--r-- | cpp/src/qpid/broker/TxAccept.cpp | 4 |
6 files changed, 20 insertions, 22 deletions
diff --git a/cpp/src/qpid/broker/DeliveryRecord.cpp b/cpp/src/qpid/broker/DeliveryRecord.cpp index 432a44ec63..930a65a522 100644 --- a/cpp/src/qpid/broker/DeliveryRecord.cpp +++ b/cpp/src/qpid/broker/DeliveryRecord.cpp @@ -179,8 +179,8 @@ void DeliveryRecord::cancel(const std::string& cancelledTag) AckRange DeliveryRecord::findRange(DeliveryRecords& records, DeliveryId first, DeliveryId last) { - ack_iterator start = find_if(records.begin(), records.end(), boost::bind(&DeliveryRecord::matchOrAfter, _1, first)); - ack_iterator end = start; + DeliveryRecords::iterator start = find_if(records.begin(), records.end(), boost::bind(&DeliveryRecord::matchOrAfter, _1, first)); + DeliveryRecords::iterator end = start; if (start != records.end()) { if (first == last) { diff --git a/cpp/src/qpid/broker/DeliveryRecord.h b/cpp/src/qpid/broker/DeliveryRecord.h index 2b2d4d0515..9985e3f7a2 100644 --- a/cpp/src/qpid/broker/DeliveryRecord.h +++ b/cpp/src/qpid/broker/DeliveryRecord.h @@ -37,25 +37,23 @@ namespace broker { class SemanticState; class DeliveryRecord; -typedef std::list<DeliveryRecord> DeliveryRecords; -typedef std::list<DeliveryRecord>::iterator ack_iterator; +typedef std::deque<DeliveryRecord> DeliveryRecords; struct AckRange { - ack_iterator start; - ack_iterator end; - AckRange(ack_iterator _start, ack_iterator _end) : start(_start), end(_end) {} + DeliveryRecords::iterator start; + DeliveryRecords::iterator end; + AckRange(DeliveryRecords::iterator _start, DeliveryRecords::iterator _end) : start(_start), end(_end) {} }; /** * Record of a delivery for which an ack is outstanding. */ -class DeliveryRecord -{ +class DeliveryRecord { QueuedMessage msg; mutable Queue::shared_ptr queue; - const std::string tag; + std::string tag; DeliveryId id; bool acquired; bool acceptExpected; @@ -63,7 +61,7 @@ class DeliveryRecord bool completed; bool ended; - const bool windowing; + bool windowing; /** * Record required credit on construction as the pointer to the @@ -72,7 +70,7 @@ class DeliveryRecord * to reallocate credit when it is completed (which could happen * after that). */ - const uint32_t credit; + uint32_t credit; public: QPID_BROKER_EXTERN DeliveryRecord(const QueuedMessage& msg, diff --git a/cpp/src/qpid/broker/DtxAck.cpp b/cpp/src/qpid/broker/DtxAck.cpp index bc7d662afb..c32c699421 100644 --- a/cpp/src/qpid/broker/DtxAck.cpp +++ b/cpp/src/qpid/broker/DtxAck.cpp @@ -26,7 +26,7 @@ using std::bind2nd; using std::mem_fun_ref; using namespace qpid::broker; -DtxAck::DtxAck(const qpid::framing::SequenceSet& acked, std::list<DeliveryRecord>& unacked) +DtxAck::DtxAck(const qpid::framing::SequenceSet& acked, DeliveryRecords& unacked) { remove_copy_if(unacked.begin(), unacked.end(), inserter(pending, pending.end()), not1(bind2nd(mem_fun_ref(&DeliveryRecord::coveredBy), &acked))); @@ -36,7 +36,7 @@ bool DtxAck::prepare(TransactionContext* ctxt) throw() { try{ //record dequeue in the store - for (ack_iterator i = pending.begin(); i != pending.end(); i++) { + for (DeliveryRecords::iterator i = pending.begin(); i != pending.end(); i++) { i->dequeue(ctxt); } return true; diff --git a/cpp/src/qpid/broker/DtxAck.h b/cpp/src/qpid/broker/DtxAck.h index d43532906a..2b7b2f0944 100644 --- a/cpp/src/qpid/broker/DtxAck.h +++ b/cpp/src/qpid/broker/DtxAck.h @@ -31,10 +31,10 @@ namespace qpid { namespace broker { class DtxAck : public TxOp{ - std::list<DeliveryRecord> pending; + DeliveryRecords pending; public: - DtxAck(const framing::SequenceSet& acked, std::list<DeliveryRecord>& unacked); + DtxAck(const framing::SequenceSet& acked, DeliveryRecords& unacked); virtual bool prepare(TransactionContext* ctxt) throw(); virtual void commit() throw(); virtual void rollback() throw(); diff --git a/cpp/src/qpid/broker/SemanticState.cpp b/cpp/src/qpid/broker/SemanticState.cpp index 3c7c6d9afa..b2df5e36a3 100644 --- a/cpp/src/qpid/broker/SemanticState.cpp +++ b/cpp/src/qpid/broker/SemanticState.cpp @@ -440,7 +440,7 @@ void SemanticState::recover(bool requeue) //unconfirmed messages re redelivered and therefore have their //id adjusted, confirmed messages are not and so the ordering //w.r.t id is lost - unacked.sort(); + std::sort(unacked.begin(), unacked.end()); } } @@ -642,12 +642,12 @@ void SemanticState::accepted(DeliveryId first, DeliveryId last) //if the messages are already completed, they can be //removed from the record - unacked.remove_if(mem_fun_ref(&DeliveryRecord::isRedundant)); + unacked.erase(std::remove_if(unacked.begin(), unacked.end(), mem_fun_ref(&DeliveryRecord::isRedundant)), unacked.end()); } } else { for_each(range.start, range.end, boost::bind(&DeliveryRecord::accept, _1, (TransactionContext*) 0)); - unacked.remove_if(mem_fun_ref(&DeliveryRecord::isRedundant)); + unacked.erase(std::remove_if(unacked.begin(), unacked.end(), mem_fun_ref(&DeliveryRecord::isRedundant)), unacked.end()); } } @@ -655,7 +655,7 @@ void SemanticState::completed(DeliveryId first, DeliveryId last) { AckRange range = findRange(first, last); for_each(range.start, range.end, boost::bind(&SemanticState::complete, this, _1)); - unacked.remove_if(mem_fun_ref(&DeliveryRecord::isRedundant)); + unacked.erase(std::remove_if(unacked.begin(), unacked.end(), mem_fun_ref(&DeliveryRecord::isRedundant)), unacked.end()); requestDispatch(); } diff --git a/cpp/src/qpid/broker/TxAccept.cpp b/cpp/src/qpid/broker/TxAccept.cpp index 73f365d509..ca128b1975 100644 --- a/cpp/src/qpid/broker/TxAccept.cpp +++ b/cpp/src/qpid/broker/TxAccept.cpp @@ -58,8 +58,8 @@ void TxAccept::RangeOps::commit() std::for_each(ranges.begin(), ranges.end(), bind(&RangeOp::commit, _1)); //now remove if isRedundant(): if (!ranges.empty()) { - ack_iterator i = ranges.front().range.start; - ack_iterator end = ranges.back().range.end; + DeliveryRecords::iterator i = ranges.front().range.start; + DeliveryRecords::iterator end = ranges.back().range.end; while (i != end) { if (i->isRedundant()) { i = unacked.erase(i); |