mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
change the NodeHash to a cuckoohash_map with CityHash
This commit is contained in:
parent
b8d0bd5d6b
commit
35d0d31350
5 changed files with 53 additions and 4 deletions
|
@ -21,9 +21,18 @@ hifi_library_search_hints("libcuckoo")
|
||||||
|
|
||||||
find_path(LIBCUCKOO_INCLUDE_DIRS libcuckoo/cuckoohash_map.hh PATH_SUFFIXES include HINTS ${LIBCUCKOO_SEARCH_DIRS})
|
find_path(LIBCUCKOO_INCLUDE_DIRS libcuckoo/cuckoohash_map.hh PATH_SUFFIXES include HINTS ${LIBCUCKOO_SEARCH_DIRS})
|
||||||
|
|
||||||
|
find_library(CITYHASH_LIBRARY_RELEASE NAME cityhash PATH_SUFFIXES lib HINTS ${LIBCUCKOO_SEARCH_DIRS})
|
||||||
|
find_library(CITYHASH_LIBRARY_DEBUG NAME cityhash PATH_SUFFIXES lib HINTS ${LIBCUCKOO_SEARCH_DIRS})
|
||||||
|
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
select_library_configurations(CITYHASH)
|
||||||
|
|
||||||
|
set(LIBCUCKOO_LIBRARIES ${CITYHASH_LIBRARY})
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(
|
find_package_handle_standard_args(
|
||||||
libcuckoo
|
libcuckoo
|
||||||
"Could NOT find libcuckoo. Read libraries/networking/externals/libcuckoo/readme.txt"
|
"Could NOT find libcuckoo. Read libraries/networking/externals/libcuckoo/readme.txt"
|
||||||
LIBCUCKOO_INCLUDE_DIRS
|
LIBCUCKOO_INCLUDE_DIRS
|
||||||
|
LIBCUCKOO_LIBRARIES
|
||||||
)
|
)
|
|
@ -25,7 +25,7 @@ endif ()
|
||||||
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
||||||
|
|
||||||
# append OpenSSL to our list of libraries to link
|
# append OpenSSL to our list of libraries to link
|
||||||
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}")
|
list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}" "${LIBCUCKOO_LIBRARIES}")
|
||||||
|
|
||||||
# append libcuckoo includes to our list of includes to bubble
|
# append libcuckoo includes to our list of includes to bubble
|
||||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${LIBCUCKOO_INCLUDE_DIRS}")
|
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${LIBCUCKOO_INCLUDE_DIRS}")
|
||||||
|
|
|
@ -26,12 +26,13 @@
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QtNetwork/QHostAddress>
|
#include <QtNetwork/QHostAddress>
|
||||||
#include <QtNetwork/QUdpSocket>
|
#include <QtNetwork/QUdpSocket>
|
||||||
|
|
||||||
#include <libcuckoo/cuckoohash_map.hh>
|
#include <libcuckoo/cuckoohash_map.hh>
|
||||||
|
|
||||||
#include "DomainHandler.h"
|
#include "DomainHandler.h"
|
||||||
#include "Node.h"
|
#include "Node.h"
|
||||||
|
#include "UUIDCityHasher.h"
|
||||||
|
|
||||||
const int MAX_PACKET_SIZE = 1500;
|
const int MAX_PACKET_SIZE = 1500;
|
||||||
|
|
||||||
|
@ -51,9 +52,10 @@ class HifiSockAddr;
|
||||||
typedef QSet<NodeType_t> NodeSet;
|
typedef QSet<NodeType_t> NodeSet;
|
||||||
|
|
||||||
typedef QSharedPointer<Node> SharedNodePointer;
|
typedef QSharedPointer<Node> SharedNodePointer;
|
||||||
typedef QHash<QUuid, SharedNodePointer> NodeHash;
|
|
||||||
Q_DECLARE_METATYPE(SharedNodePointer)
|
Q_DECLARE_METATYPE(SharedNodePointer)
|
||||||
|
|
||||||
|
typedef cuckoohash_map<QUuid, SharedNodePointer, UUIDCityHasher > NodeHash;
|
||||||
|
|
||||||
typedef quint8 PingType_t;
|
typedef quint8 PingType_t;
|
||||||
namespace PingType {
|
namespace PingType {
|
||||||
const PingType_t Agnostic = 0;
|
const PingType_t Agnostic = 0;
|
||||||
|
@ -159,7 +161,7 @@ protected:
|
||||||
void changeSocketBufferSizes(int numBytes);
|
void changeSocketBufferSizes(int numBytes);
|
||||||
|
|
||||||
QUuid _sessionUUID;
|
QUuid _sessionUUID;
|
||||||
NodeHash _nodeHash;
|
cuckoohash_map<QByteArray, SharedNodePointer> _nodeHash;
|
||||||
QMutex _nodeHashMutex;
|
QMutex _nodeHashMutex;
|
||||||
QUdpSocket _nodeSocket;
|
QUdpSocket _nodeSocket;
|
||||||
QUdpSocket* _dtlsSocket;
|
QUdpSocket* _dtlsSocket;
|
||||||
|
|
12
libraries/networking/src/UUIDCityHasher.cpp
Normal file
12
libraries/networking/src/UUIDCityHasher.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
//
|
||||||
|
// UUIDCityHasher.cpp
|
||||||
|
// libraries/networking/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2014-11-05.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "UUIDCityHasher.h"
|
26
libraries/networking/src/UUIDCityHasher.h
Normal file
26
libraries/networking/src/UUIDCityHasher.h
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// UUIDCityHasher.h
|
||||||
|
// libraries/networking/src
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 2014-11-05.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_UUIDCityHasher_h
|
||||||
|
#define hifi_UUIDCityHasher_h
|
||||||
|
|
||||||
|
#include <libcuckoo/city.h>
|
||||||
|
|
||||||
|
#include "UUID.h"
|
||||||
|
|
||||||
|
class UUIDCityHasher {
|
||||||
|
public:
|
||||||
|
size_t operator()(const QUuid& key) const {
|
||||||
|
return CityHash64(key.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_UUIDCityHasher_h
|
Loading…
Reference in a new issue