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_LINEAR_H
14 #define JUNCTION_EXTRA_IMPL_MAPADAPTER_LINEAR_H
16 #include <junction/Core.h>
17 #include <junction/QSBR.h>
18 #include <junction/ConcurrentMap_Linear.h>
19 #include <turf/Util.h>
26 static TURF_CONSTEXPR const char* getMapName() { return "Junction Linear map"; }
33 QSBR::Context m_qsbrContext;
36 ThreadContext(MapAdapter&, ureg) {
39 void registerThread() {
40 m_qsbrContext = DefaultQSBR.createContext();
43 void unregisterThread() {
44 DefaultQSBR.destroyContext(m_qsbrContext);
48 DefaultQSBR.update(m_qsbrContext);
52 typedef ConcurrentMap_Linear<u32, void*> Map;
54 static ureg getInitialCapacity(ureg maxPopulation) {
55 return turf::util::roundUpPowerOf2(maxPopulation / 4);
60 } // namespace junction
62 #endif // JUNCTION_EXTRA_IMPL_MAPADAPTER_LINEAR_H