mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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_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)
|
||||
find_package_handle_standard_args(
|
||||
libcuckoo
|
||||
"Could NOT find libcuckoo. Read libraries/networking/externals/libcuckoo/readme.txt"
|
||||
LIBCUCKOO_INCLUDE_DIRS
|
||||
LIBCUCKOO_LIBRARIES
|
||||
)
|
|
@ -25,7 +25,7 @@ endif ()
|
|||
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
||||
|
||||
# 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
|
||||
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${LIBCUCKOO_INCLUDE_DIRS}")
|
||||
|
|
|
@ -26,12 +26,13 @@
|
|||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <QtNetwork/QUdpSocket>
|
||||
#include <QtNetwork/QUdpSocket>
|
||||
|
||||
#include <libcuckoo/cuckoohash_map.hh>
|
||||
|
||||
#include "DomainHandler.h"
|
||||
#include "Node.h"
|
||||
#include "UUIDCityHasher.h"
|
||||
|
||||
const int MAX_PACKET_SIZE = 1500;
|
||||
|
||||
|
@ -51,9 +52,10 @@ class HifiSockAddr;
|
|||
typedef QSet<NodeType_t> NodeSet;
|
||||
|
||||
typedef QSharedPointer<Node> SharedNodePointer;
|
||||
typedef QHash<QUuid, SharedNodePointer> NodeHash;
|
||||
Q_DECLARE_METATYPE(SharedNodePointer)
|
||||
|
||||
typedef cuckoohash_map<QUuid, SharedNodePointer, UUIDCityHasher > NodeHash;
|
||||
|
||||
typedef quint8 PingType_t;
|
||||
namespace PingType {
|
||||
const PingType_t Agnostic = 0;
|
||||
|
@ -159,7 +161,7 @@ protected:
|
|||
void changeSocketBufferSizes(int numBytes);
|
||||
|
||||
QUuid _sessionUUID;
|
||||
NodeHash _nodeHash;
|
||||
cuckoohash_map<QByteArray, SharedNodePointer> _nodeHash;
|
||||
QMutex _nodeHashMutex;
|
||||
QUdpSocket _nodeSocket;
|
||||
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