summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2013-08-06 15:00:47 +0000
committerAlan Conway <aconway@apache.org>2013-08-06 15:00:47 +0000
commit77f89f2c2b5ff6b69ff51ff16619c06f3a4e51f6 (patch)
treecae68ea5f6f6feed1fc6a89732fd531f12b24ee5
parent66efa54f6d9621ad4dcd9a0a86842c4a835af971 (diff)
downloadqpid-python-77f89f2c2b5ff6b69ff51ff16619c06f3a4e51f6.tar.gz
NO-JIRA: HA remove use of boost_hash, failes to build on some compilers.
Removed use of boost::hash entirely, build problems on RHEL5. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1510988 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--cpp/src/qpid/ha/AlternateExchangeSetter.h1
-rw-r--r--cpp/src/qpid/ha/BrokerInfo.h5
-rw-r--r--cpp/src/qpid/ha/Primary.h6
-rw-r--r--cpp/src/qpid/ha/PrimaryTxObserver.h3
-rw-r--r--cpp/src/qpid/ha/QueueGuard.h4
-rw-r--r--cpp/src/qpid/ha/QueueReplicator.h5
-rw-r--r--cpp/src/qpid/ha/QueueSnapshots.h10
-rw-r--r--cpp/src/qpid/ha/RemoteBackup.h8
-rw-r--r--cpp/src/qpid/ha/hash.h71
9 files changed, 91 insertions, 22 deletions
diff --git a/cpp/src/qpid/ha/AlternateExchangeSetter.h b/cpp/src/qpid/ha/AlternateExchangeSetter.h
index 2386a01084..fbf4755e7d 100644
--- a/cpp/src/qpid/ha/AlternateExchangeSetter.h
+++ b/cpp/src/qpid/ha/AlternateExchangeSetter.h
@@ -25,7 +25,6 @@
#include "qpid/log/Statement.h"
#include "qpid/broker/Exchange.h"
#include "qpid/broker/ExchangeRegistry.h"
-#include "boost/function.hpp"
#include <map>
namespace qpid {
diff --git a/cpp/src/qpid/ha/BrokerInfo.h b/cpp/src/qpid/ha/BrokerInfo.h
index 8e62665088..87d51f5113 100644
--- a/cpp/src/qpid/ha/BrokerInfo.h
+++ b/cpp/src/qpid/ha/BrokerInfo.h
@@ -23,12 +23,12 @@
*/
#include "types.h"
+#include "hash.h"
#include "qpid/Url.h"
#include "qpid/framing/FieldTable.h"
#include "qpid/types/Uuid.h"
#include "qpid/types/Variant.h"
#include "qpid/sys/unordered_map.h"
-#include <boost/functional/hash.hpp>
#include <string>
#include <iosfwd>
#include <vector>
@@ -43,8 +43,7 @@ class BrokerInfo
{
public:
typedef std::set<BrokerInfo> Set;
- typedef qpid::sys::unordered_map<types::Uuid, BrokerInfo,
- boost::hash<types::Uuid> > Map;
+ typedef qpid::sys::unordered_map<types::Uuid, BrokerInfo, Hasher<types::Uuid> > Map;
BrokerInfo();
BrokerInfo(const types::Uuid& id, BrokerStatus, const Address& = Address());
diff --git a/cpp/src/qpid/ha/Primary.h b/cpp/src/qpid/ha/Primary.h
index c13d60991e..0affc49508 100644
--- a/cpp/src/qpid/ha/Primary.h
+++ b/cpp/src/qpid/ha/Primary.h
@@ -23,13 +23,13 @@
*/
#include "types.h"
+#include "hash.h"
#include "BrokerInfo.h"
#include "ReplicationTest.h"
#include "Role.h"
#include "qpid/sys/Mutex.h"
#include "qpid/sys/unordered_map.h"
#include <boost/shared_ptr.hpp>
-#include <boost/functional/hash.hpp>
#include <boost/intrusive_ptr.hpp>
#include <string>
@@ -105,13 +105,13 @@ class Primary : public Role
private:
typedef sys::unordered_map<
- types::Uuid, RemoteBackupPtr, boost::hash<types::Uuid> > BackupMap;
+ types::Uuid, RemoteBackupPtr, Hasher<types::Uuid> > BackupMap;
typedef std::set<RemoteBackupPtr > BackupSet;
typedef std::pair<types::Uuid, boost::shared_ptr<broker::Queue> > UuidQueue;
typedef sys::unordered_map<UuidQueue, ReplicatingSubscription*,
- boost::hash<UuidQueue> > ReplicaMap;
+ Hasher<UuidQueue> > ReplicaMap;
RemoteBackupPtr backupConnect(const BrokerInfo&, broker::Connection&, sys::Mutex::ScopedLock&);
void backupDisconnect(RemoteBackupPtr, sys::Mutex::ScopedLock&);
diff --git a/cpp/src/qpid/ha/PrimaryTxObserver.h b/cpp/src/qpid/ha/PrimaryTxObserver.h
index 2c207c55fa..4efdf06c42 100644
--- a/cpp/src/qpid/ha/PrimaryTxObserver.h
+++ b/cpp/src/qpid/ha/PrimaryTxObserver.h
@@ -29,7 +29,6 @@
#include "qpid/types/Uuid.h"
#include "qpid/sys/unordered_map.h"
#include "qpid/sys/Monitor.h"
-#include <boost/functional/hash.hpp>
#include <boost/enable_shared_from_this.hpp>
namespace qpid {
@@ -79,7 +78,7 @@ class PrimaryTxObserver : public broker::TransactionObserver,
private:
class Exchange;
typedef qpid::sys::unordered_map<
- QueuePtr, ReplicationIdSet, boost::hash<QueuePtr> > QueueIdsMap;
+ QueuePtr, ReplicationIdSet, Hasher<QueuePtr> > QueueIdsMap;
void membership(const BrokerInfo::Map&);
void deduplicate(sys::Mutex::ScopedLock&);
diff --git a/cpp/src/qpid/ha/QueueGuard.h b/cpp/src/qpid/ha/QueueGuard.h
index 5a5f80996d..33967970eb 100644
--- a/cpp/src/qpid/ha/QueueGuard.h
+++ b/cpp/src/qpid/ha/QueueGuard.h
@@ -23,12 +23,12 @@
*/
#include "types.h"
+#include "hash.h"
#include "qpid/types/Uuid.h"
#include "qpid/sys/Mutex.h"
#include "qpid/sys/unordered_map.h"
#include <boost/shared_ptr.hpp>
#include <boost/intrusive_ptr.hpp>
-#include <boost/functional/hash.hpp>
#include <deque>
#include <set>
@@ -89,7 +89,7 @@ class QueueGuard {
class QueueObserver;
typedef qpid::sys::unordered_map<ReplicationId,
boost::intrusive_ptr<broker::AsyncCompletion>,
- boost::hash<ReplicationId> > Delayed;
+ Hasher<ReplicationId> > Delayed;
bool complete(ReplicationId, sys::Mutex::ScopedLock &);
void complete(Delayed::iterator, sys::Mutex::ScopedLock &);
diff --git a/cpp/src/qpid/ha/QueueReplicator.h b/cpp/src/qpid/ha/QueueReplicator.h
index 24baeb9a89..cc6c7ed2a7 100644
--- a/cpp/src/qpid/ha/QueueReplicator.h
+++ b/cpp/src/qpid/ha/QueueReplicator.h
@@ -23,10 +23,9 @@
*/
#include "BrokerInfo.h"
+#include "hash.h"
#include "qpid/broker/Exchange.h"
#include <boost/enable_shared_from_this.hpp>
-#include <boost/functional/hash.hpp>
-#include <boost/function.hpp>
#include <iosfwd>
namespace qpid {
@@ -106,7 +105,7 @@ class QueueReplicator : public broker::Exchange,
private:
typedef qpid::sys::unordered_map<
- ReplicationId, QueuePosition, boost::hash<int32_t> > PositionMap;
+ ReplicationId, QueuePosition, Hasher<ReplicationId> > PositionMap;
class ErrorListener;
class QueueObserver;
diff --git a/cpp/src/qpid/ha/QueueSnapshots.h b/cpp/src/qpid/ha/QueueSnapshots.h
index c12ee743e8..d067b983d1 100644
--- a/cpp/src/qpid/ha/QueueSnapshots.h
+++ b/cpp/src/qpid/ha/QueueSnapshots.h
@@ -24,6 +24,7 @@
#include "QueueSnapshot.h"
+#include "hash.h"
#include "qpid/assert.h"
#include "qpid/broker/BrokerObserver.h"
@@ -31,7 +32,6 @@
#include "qpid/sys/Mutex.h"
#include <boost/shared_ptr.hpp>
-#include <boost/functional/hash.hpp>
namespace qpid {
namespace ha {
@@ -67,10 +67,10 @@ class QueueSnapshots : public broker::BrokerObserver
}
private:
- typedef qpid::sys::unordered_map<
- boost::shared_ptr<broker::Queue>, boost::shared_ptr<QueueSnapshot>,
- boost::hash<boost::shared_ptr<broker::Queue> > > SnapshotMap;
-
+ typedef qpid::sys::unordered_map<boost::shared_ptr<broker::Queue>,
+ boost::shared_ptr<QueueSnapshot>,
+ Hasher<boost::shared_ptr<broker::Queue> >
+ > SnapshotMap;
SnapshotMap snapshots;
mutable sys::Mutex lock;
};
diff --git a/cpp/src/qpid/ha/RemoteBackup.h b/cpp/src/qpid/ha/RemoteBackup.h
index d2533e8b5c..b9e2e1a496 100644
--- a/cpp/src/qpid/ha/RemoteBackup.h
+++ b/cpp/src/qpid/ha/RemoteBackup.h
@@ -25,8 +25,8 @@
#include "ReplicationTest.h"
#include "BrokerInfo.h"
#include "types.h"
+#include "hash.h"
#include "qpid/sys/unordered_map.h"
-#include <boost/functional/hash.hpp>
#include <set>
namespace qpid {
@@ -96,8 +96,10 @@ class RemoteBackup
void startCatchup() { started = true; }
private:
- typedef qpid::sys::unordered_map<QueuePtr, GuardPtr,
- boost::hash<QueuePtr> > GuardMap;
+ typedef qpid::sys::unordered_map<
+ QueuePtr, GuardPtr, Hasher<boost::shared_ptr<broker::Queue> >
+ > GuardMap;
+
typedef std::set<QueuePtr> QueueSet;
std::string logPrefix;
diff --git a/cpp/src/qpid/ha/hash.h b/cpp/src/qpid/ha/hash.h
new file mode 100644
index 0000000000..8a7f3c00fe
--- /dev/null
+++ b/cpp/src/qpid/ha/hash.h
@@ -0,0 +1,71 @@
+#ifndef QPID_HA_HASH_H
+#define QPID_HA_HASH_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "qpid/types/Uuid.h"
+#include <boost/shared_ptr.hpp>
+#include <utility>
+
+namespace qpid {
+namespace ha {
+
+// TODO aconway 2013-08-06: would like to use boost::hash or std::hash here
+// but not available/working on some older compilers.
+// Add overloads as needed.
+
+inline std::size_t hashValue(bool v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(char v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(unsigned char v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(signed char v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(short v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(unsigned short v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(int v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(unsigned int v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(long v) { return static_cast<std::size_t>(v); }
+inline std::size_t hashValue(unsigned long v) { return static_cast<std::size_t>(v); }
+
+inline std::size_t hashValue(const types::Uuid& v) { return v.hash(); }
+
+template <class T> inline std::size_t hashValue(T* v) {
+ std::size_t x = static_cast<std::size_t>(reinterpret_cast<std::ptrdiff_t>(v));
+ return x + (x >> 3);
+}
+
+template <class T> inline void hashCombine(std::size_t& seed, const T& v) {
+ seed ^= hashValue(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
+}
+
+template <class T, class U> inline size_t hashValue(const std::pair<T,U>& v) {
+ std::size_t seed = 0;
+ hashCombine(seed, v.first);
+ hashCombine(seed, v.second);
+ return seed;
+}
+
+template<class T> struct Hasher {
+ size_t operator()(const T& v) const { return hashValue(v); }
+};
+
+}} // namespace qpid::ha
+
+#endif /*!QPID_HA_HASH_H*/