summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing/SequenceNumber.h
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2009-06-16 21:21:09 +0000
committerAlan Conway <aconway@apache.org>2009-06-16 21:21:09 +0000
commit80d65b38008d9b7f31c825508819f9600d63b63c (patch)
tree316862bff35f1cae6f0d1152dcf4a6e3b0f967ed /cpp/src/qpid/framing/SequenceNumber.h
parentf5e98a6dfb8c4defe22755340f440e6f16c2559a (diff)
downloadqpid-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/SequenceNumber.h')
-rw-r--r--cpp/src/qpid/framing/SequenceNumber.h39
1 files changed, 21 insertions, 18 deletions
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;