Tervel  1.0.0
A collection of wait-free containers and algorithms.
cliff_api.h
Go to the documentation of this file.
1 /*
2 #The MIT License (MIT)
3 #
4 #Copyright (c) 2015 University of Central Florida's Computer Software Engineering
5 #Scalable & Secure Systems (CSE - S3) Lab
6 #
7 #Permission is hereby granted, free of charge, to any person obtaining a copy
8 #of this software and associated documentation files (the "Software"), to deal
9 #in the Software without restriction, including without limitation the rights
10 #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 #copies of the Software, and to permit persons to whom the Software is
12 #furnished to do so, subject to the following conditions:
13 #
14 #The above copyright notice and this permission notice shall be included in
15 #all copies or substantial portions of the Software.
16 #
17 #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 #THE SOFTWARE.
24 #
25 */
26 
27 #ifndef BLANK_MAP_API_H
28 #define BLANK_MAP_API_H
29 
30  extern "C" {
31 #include "/Libraries/nbds.0.4.3/include/common.h"
32 #include "/Libraries/nbds.0.4.3/include/nstring.h"
33 #include "/Libraries/nbds.0.4.3/include/runtime.h"
34 #include "/Libraries/nbds.0.4.3/include/map.h"
35 #include "/Libraries/nbds.0.4.3/include/rcu.h"
36 #include "/Libraries/nbds.0.4.3/include/list.h"
37 #include "/Libraries/nbds.0.4.3/include/skiplist.h"
38 #include "/Libraries/nbds.0.4.3/include/hashtable.h"
39  }
40 
41 template<class Key, class Value>
42 class TestClass {
43  public:
44  TestClass(size_t num_threads, size_t capacity) {
45  container = map_alloc(&MAP_IMPL_HT, NULL);
46  }
47 
48  std::string toString() {
49  return "Cliff Click";
50  }
51 
52  void attach_thread() {}
53 
54  void detach_thread() {}
55 
56  bool find(Key key, Value &value) {
57  map_key_t temp = (map_key_t) key;
58 
59  map_val_t temp2 = map_get(container, temp);
60  if (temp2 != 0) {
61  value = temp2;
62  return true;
63  } else {
64  return false;
65  }
66  }
67 
68  bool insert(Key key, Value value) {
69  map_val_t temp = map_add(container, (map_key_t) key, (map_val_t) value);
70  if (temp == 0) {
71  return true;
72  } else {
73  return false;
74  }
75  }
76 
77  bool update(Key key, Value &value_expected, Value value_new) {
78  map_val_t temp = map_cas(container, (map_key_t) key,
79  (map_val_t) value_expected, (map_val_t) value_new);
80  if (temp == value_expected) {
81  return true;
82  } else {
83  value_expected = false;
84  return false;
85  }
86  }
87 
88  bool remove(Key key) {
89  map_val_t temp = map_remove(container, (map_key_t) key);
90  if (temp != 0) {
91  return true;
92  } else {
93  return false;
94  }
95  }
96 
97  size_t size() {
98  return -1;
99  }
100 
101  private:
102  map_t *container;
103 };
104 
105 #endif //
void detach_thread()
Definition: cliff_api.h:54
bool insert(Key key, Value value)
Definition: cliff_api.h:68
map_t * container
Definition: cliff_api.h:102
void attach_thread()
Definition: cliff_api.h:52
bool update(Key key, Value &value_expected, Value value_new)
Definition: cliff_api.h:77
uint64_t Value
Definition: testObject.h:59
size_t size()
Definition: cliff_api.h:97
bool find(Key key, Value &value)
Definition: cliff_api.h:56
Definition: blank_api.h:31
TestClass(size_t num_threads, size_t capacity)
Definition: cliff_api.h:44
std::string toString()
Definition: cliff_api.h:48