diff options
| author | Alan Conway <aconway@apache.org> | 2009-06-16 21:21:09 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2009-06-16 21:21:09 +0000 |
| commit | 80d65b38008d9b7f31c825508819f9600d63b63c (patch) | |
| tree | 316862bff35f1cae6f0d1152dcf4a6e3b0f967ed /cpp/src/qpid/framing | |
| parent | f5e98a6dfb8c4defe22755340f440e6f16c2559a (diff) | |
| download | qpid-python-80d65b38008d9b7f31c825508819f9600d63b63c.tar.gz | |
Performance improvements in AggregateOutput and SemanticState.
Replaced AggregateOutput hierarchy with a flat list per connection
holding only the OutputTasks that are potentially active. Tasks are
droped from the list as soon as they return false, and added back when
they may have output.
Inlined frequently-used SequenceNumber functions.
Replace std::list in QueueListeners with std::vector.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@785408 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing')
| -rw-r--r-- | cpp/src/qpid/framing/SequenceNumber.cpp | 60 | ||||
| -rw-r--r-- | cpp/src/qpid/framing/SequenceNumber.h | 39 |
2 files changed, 21 insertions, 78 deletions
diff --git a/cpp/src/qpid/framing/SequenceNumber.cpp b/cpp/src/qpid/framing/SequenceNumber.cpp index cac4e6681e..e61e3f2edf 100644 --- a/cpp/src/qpid/framing/SequenceNumber.cpp +++ b/cpp/src/qpid/framing/SequenceNumber.cpp @@ -26,60 +26,6 @@ using qpid::framing::SequenceNumber; using qpid::framing::Buffer; -SequenceNumber::SequenceNumber() : value(0) {} - -SequenceNumber::SequenceNumber(uint32_t v) : value((int32_t) v) {} - -bool SequenceNumber::operator==(const SequenceNumber& other) const -{ - return value == other.value; -} - -bool SequenceNumber::operator!=(const SequenceNumber& other) const -{ - return !(value == other.value); -} - - -SequenceNumber& SequenceNumber::operator++() -{ - value = value + 1; - return *this; -} - -const SequenceNumber SequenceNumber::operator++(int) -{ - SequenceNumber old(value); - value = value + 1; - return old; -} - -SequenceNumber& SequenceNumber::operator--() -{ - value = value - 1; - return *this; -} - -bool SequenceNumber::operator<(const SequenceNumber& other) const -{ - return (value - other.value) < 0; -} - -bool SequenceNumber::operator>(const SequenceNumber& other) const -{ - return other < *this; -} - -bool SequenceNumber::operator<=(const SequenceNumber& other) const -{ - return *this == other || *this < other; -} - -bool SequenceNumber::operator>=(const SequenceNumber& other) const -{ - return *this == other || *this > other; -} - void SequenceNumber::encode(Buffer& buffer) const { buffer.putLong(value); @@ -97,12 +43,6 @@ uint32_t SequenceNumber::encodedSize() const { namespace qpid { namespace framing { -int32_t operator-(const SequenceNumber& a, const SequenceNumber& b) -{ - int32_t result = a.value - b.value; - return result; -} - std::ostream& operator<<(std::ostream& o, const SequenceNumber& n) { return o << n.getValue(); } diff --git a/cpp/src/qpid/framing/SequenceNumber.h b/cpp/src/qpid/framing/SequenceNumber.h index 3b18ce1360..c208739cdd 100644 --- a/cpp/src/qpid/framing/SequenceNumber.h +++ b/cpp/src/qpid/framing/SequenceNumber.h @@ -22,6 +22,7 @@ #define _framing_SequenceNumber_h #include "amqp_types.h" +#include <boost/operators.hpp> #include <iosfwd> #include "qpid/CommonImportExport.h" @@ -33,35 +34,37 @@ class Buffer; /** * 4-byte sequence number that 'wraps around'. */ -class SequenceNumber +class SequenceNumber : public +boost::equality_comparable< + SequenceNumber, boost::less_than_comparable< + SequenceNumber, boost::incrementable< + SequenceNumber, boost::decrementable<SequenceNumber> > > > { int32_t value; - public: - QPID_COMMON_EXTERN SequenceNumber(); - QPID_COMMON_EXTERN SequenceNumber(uint32_t v); - - QPID_COMMON_EXTERN SequenceNumber& operator++();//prefix ++ - QPID_COMMON_EXTERN const SequenceNumber operator++(int);//postfix ++ - QPID_COMMON_EXTERN SequenceNumber& operator--();//prefix ++ - QPID_COMMON_EXTERN bool operator==(const SequenceNumber& other) const; - QPID_COMMON_EXTERN bool operator!=(const SequenceNumber& other) const; - QPID_COMMON_EXTERN bool operator<(const SequenceNumber& other) const; - QPID_COMMON_EXTERN bool operator>(const SequenceNumber& other) const; - QPID_COMMON_EXTERN bool operator<=(const SequenceNumber& other) const; - QPID_COMMON_EXTERN bool operator>=(const SequenceNumber& other) const; - uint32_t getValue() const { return (uint32_t) value; } - operator uint32_t() const { return (uint32_t) value; } - - QPID_COMMON_EXTERN friend int32_t operator-(const SequenceNumber& a, const SequenceNumber& b); + public: + SequenceNumber(uint32_t v=0) : value(v) {} + + SequenceNumber& operator++() { ++value; return *this; } + SequenceNumber& operator--() { --value; return *this; } + bool operator==(const SequenceNumber& other) const { return value == other.value; } + bool operator<(const SequenceNumber& other) const { return (value - other.value) < 0; } + uint32_t getValue() const { return uint32_t(value); } + operator uint32_t() const { return uint32_t(value); } void encode(Buffer& buffer) const; void decode(Buffer& buffer); uint32_t encodedSize() const; template <class S> void serialize(S& s) { s(value); } + + friend inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b); }; +inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b) { + return int32_t(a.value - b.value); +} + struct Window { SequenceNumber hwm; |
