]> pd.if.org Git - nbds/blobdiff - include/map.h
more header file refactoring
[nbds] / include / map.h
index 357b66895f3b16ace6ae137226ab2599818e938a..4d8b78f39ab22147ee12b7db5fd0f28eaa727ef6 100644 (file)
@@ -4,12 +4,9 @@
 #include "datatype.h"
 
 typedef struct map map_t;
+typedef struct map_impl map_impl_t;
 
-typedef const struct map_impl *map_type_t;
-
-extern map_type_t MAP_TYPE_HASHTABLE;
-
-map_t *  map_alloc  (map_type_t map_type, const datatype_t *key_type);
+map_t *  map_alloc  (const map_impl_t *map_impl, const datatype_t *key_type);
 uint64_t map_get    (map_t *map, void *key);
 uint64_t map_set    (map_t *map, void *key, uint64_t new_val);
 uint64_t map_add    (map_t *map, void *key, uint64_t new_val);
@@ -20,4 +17,28 @@ uint64_t map_count  (map_t *map);
 void     map_print  (map_t *map);
 void     map_free   (map_t *map);
 
+/////////////////////////////////////////////////////////////////////////////////////
+
+#define CAS_EXPECT_DOES_NOT_EXIST ( 0)
+#define CAS_EXPECT_EXISTS         (-1)
+#define CAS_EXPECT_WHATEVER       (-2)
+
+typedef void *   (*map_alloc_t)  (const datatype_t *);
+typedef uint64_t (*map_cas_t)    (void *, void *, uint64_t, uint64_t);
+typedef uint64_t (*map_get_t)    (void *, void *);
+typedef uint64_t (*map_remove_t) (void *, void *);
+typedef uint64_t (*map_count_t)  (void *);
+typedef void     (*map_print_t)  (void *);
+typedef void     (*map_free_t)   (void *);
+
+struct map_impl {
+    map_alloc_t  alloc;
+    map_cas_t    cas;
+    map_get_t    get;
+    map_remove_t remove;
+    map_count_t  count;
+    map_print_t  print;
+    map_free_t   free_;
+};
+
 #endif//MAP_H