]> pd.if.org Git - nbds/blobdiff - map/skiplist.c
more header file refactoring
[nbds] / map / skiplist.c
index ad05dd190f25bbae2e7df828d87fe340e3f53925..52d7f1a622a40242029e0e15cf273b3b875970a4 100644 (file)
 #include <stdio.h>
 #include <string.h>
 
-#define ENABLE_TRACE
-
 #include "common.h"
 #include "runtime.h"
-#include "mlocal.h"
+#include "skiplist.h"
 #include "mem.h"
-#include "tls.h"
 
 // Setting MAX_LEVEL to 0 essentially makes this data structure the Harris-Michael lock-free list (in list.c).
 #define MAX_LEVEL 31
@@ -43,13 +40,6 @@ struct sl {
     const datatype_t *key_type;
 };
 
-static const map_impl_t sl_map_impl = { 
-    (map_alloc_t)sl_alloc, (map_cas_t)sl_cas, (map_get_t)sl_lookup, (map_remove_t)sl_remove, 
-    (map_count_t)sl_count, (map_print_t)sl_print, (map_free_t)sl_free
-};
-
-const map_impl_t *MAP_TYPE_SKIPLIST = &sl_map_impl;
-
 static int random_level (void) {
     unsigned r = nbd_rand();
     if (r & 1)
@@ -409,7 +399,7 @@ uint64_t sl_remove (skiplist_t *sl, void *key) {
     TRACE("s1", "sl_remove: marked item %p removed at level 0", item, 0);
 
     // Atomically swap out the item's value in case another thread is updating the item while we are 
-    // removing it. This establishes which one occurs first, the update or the remove. 
+    // removing it. This establishes which operation occurs first logically, the update or the remove. 
     uint64_t val = SYNC_SWAP(&item->val, DOES_NOT_EXIST); 
     TRACE("s2", "sl_remove: replaced item %p's value with DOES_NOT_EXIT", item, 0);