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_NBDS_H
14 #define JUNCTION_EXTRA_IMPL_MAPADAPTER_NBDS_H
16 #include <junction/Core.h>
18 #if !JUNCTION_WITH_NBDS
19 #error "You must configure with JUNCTION_WITH_NBDS=1!"
25 #include <../runtime/rlocal.h>
26 #include <hashtable.h>
34 static TURF_CONSTEXPR const char* getMapName() { return "nbds hashtable_t"; }
44 ThreadContext(MapAdapter&, ureg threadIndex) : m_threadIndex(threadIndex) {
47 void registerThread() {
48 rcu_thread_init(m_threadIndex);
51 void unregisterThread() {
65 m_map = ht_alloc(NULL);
72 void assign(u32 key, void* value) {
73 ht_cas(m_map, key, CAS_EXPECT_WHATEVER, (map_val_t) value);
77 return (void*) ht_get(m_map, key);
81 ht_remove(m_map, key);
85 static ureg getInitialCapacity(ureg) {
91 } // namespace junction
93 #endif // JUNCTION_EXTRA_IMPL_MAPADAPTER_NBDS_H