1 #ifndef _JUNCTION_TEST_H
2 #define _JUNCTION_TEST_H
4 #include <junction/ConcurrentMap_Crude.h>
5 #include <junction/ConcurrentMap_Grampa.h>
6 #include <junction/ConcurrentMap_Leapfrog.h>
7 #include <junction/ConcurrentMap_Linear.h>
9 #include <cds_test/stress_test.h>
10 #include <cds_test/stress_test_util.h>
18 namespace junction_test {
20 typedef junction::ConcurrentMap_Grampa<size_t, size_t> GrampaMap;
21 typedef junction::ConcurrentMap_Linear<size_t, size_t> LinearMap;
22 typedef junction::ConcurrentMap_Leapfrog<size_t, size_t> LeapfrogMap;
23 typedef junction::ConcurrentMap_Crude<size_t, size_t> CrudeMap;
25 template <typename Map, typename Key, typename Value>
26 static bool map_insert(Map* map, Key key, Value value) {
27 auto iter = map->insertOrFind(key);
28 if (!iter.getValue() || iter.getValue() != value) {
29 // Insert/update the <key,value> pair
30 iter.assignValue(value);
37 template <typename Map, typename Key>
38 static bool map_delete(Map* map, Key key) {
39 auto iter = map->find(key);
40 if (iter.getValue()) {
48 template <typename Map, typename Key> static bool map_find(Map* map, Key key) {
49 auto iter = map->find(key);
50 if (iter.getValue()) {
57 // Specialization for CrudeMap
58 template <typename Key, typename Value>
59 static bool map_insert(CrudeMap* map, Key key, Value value) {
60 auto old_val = map->get(key);
61 if (!old_val || old_val != value) {
62 map->assign(key, value);
69 template <typename Key> static bool map_delete(CrudeMap* map, Key key) {
71 map->assign(key, ((Key)0));
78 template <typename Key> static bool map_find(CrudeMap* map, Key key) {
79 return map->get(key) != ((Key)0);
82 } // namespace junction_test