1 /*------------------------------------------------------------------------
2 Junction: Concurrent data structures in C++
3 Copyright (c) 2016 Jeff Preshing
5 Distributed under the Simplified BSD License.
6 Original location: https://github.com/preshing/junction
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the LICENSE file for more information.
11 ------------------------------------------------------------------------*/
13 #ifndef JUNCTION_EXTRA_IMPL_MAPADAPTER_LIBCUCKOO_H
14 #define JUNCTION_EXTRA_IMPL_MAPADAPTER_LIBCUCKOO_H
16 #include <junction/Core.h>
18 #if !JUNCTION_WITH_LIBCUCKOO
19 #error "You must configure with JUNCTION_WITH_LIBCUCKOO=1!"
22 #include <libcuckoo/cuckoohash_map.hh>
29 static TURF_CONSTEXPR const char* getMapName() { return "libcuckoo cuckoohash_map"; }
36 ThreadContext(MapAdapter&, ureg) {
39 void registerThread() {
42 void unregisterThread() {
51 cuckoohash_map<u32, void*> m_map;
54 Map(ureg capacity) : m_map(capacity) {
57 void assign(u32 key, void* value) {
58 m_map.insert(key, value);
63 return m_map.find(key, result) ? result : NULL;
71 static ureg getInitialCapacity(ureg maxPopulation) {
72 return maxPopulation / 4;
77 } // namespace junction
79 #endif // JUNCTION_EXTRA_IMPL_MAPADAPTER_LIBCUCKOO_H