From 92be0a347cdfd9c407611982c72938ecde777a8c Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 25 May 2009 18:20:50 +0000 Subject: PollableQueue optimization - replace deque with vector. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@778464 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/PollableQueue.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'cpp/src/qpid/cluster/PollableQueue.h') diff --git a/cpp/src/qpid/cluster/PollableQueue.h b/cpp/src/qpid/cluster/PollableQueue.h index a44c39ad85..db98faa9da 100644 --- a/cpp/src/qpid/cluster/PollableQueue.h +++ b/cpp/src/qpid/cluster/PollableQueue.h @@ -37,24 +37,27 @@ template class PollableQueue : public sys::PollableQueue { typedef boost::function Callback; typedef boost::function ErrorCallback; - PollableQueue(Callback f, ErrorCallback err, const std::string& msg, const boost::shared_ptr& poller) - : sys::PollableQueue(boost::bind(&PollableQueue::handleBatch, this, _1), poller), + PollableQueue(Callback f, ErrorCallback err, const std::string& msg, + const boost::shared_ptr& poller) + : sys::PollableQueue(boost::bind(&PollableQueue::handleBatch, this, _1), + poller), callback(f), error(err), message(msg) {} - void handleBatch(typename sys::PollableQueue::Queue& values) { + typename sys::PollableQueue::Batch::const_iterator + handleBatch(const typename sys::PollableQueue::Batch& values) { try { - typename sys::PollableQueue::Queue::iterator i = values.begin(); + typename sys::PollableQueue::Batch::const_iterator i = values.begin(); while (i != values.end() && !this->isStopped()) { callback(*i); ++i; } - values.erase(values.begin(), i); + return i; } catch (const std::exception& e) { QPID_LOG(error, message << ": " << e.what()); - values.clear(); this->stop(); error(); + return values.end(); } } -- cgit v1.2.1