snapshot v4/p5; update, etc.
This commit is contained in:
parent
bb283840ce
commit
45bb58a6ca
1 changed files with 17 additions and 9 deletions
22
include/sl.h
22
include/sl.h
|
@ -711,7 +711,8 @@ __skip_read_rdtsc(void)
|
||||||
if (preserved) \
|
if (preserved) \
|
||||||
*preserved = dest; \
|
*preserved = dest; \
|
||||||
\
|
\
|
||||||
return rc; \
|
rc = 1; \
|
||||||
|
return -rc; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
/** \
|
/** \
|
||||||
|
@ -810,10 +811,10 @@ __skip_read_rdtsc(void)
|
||||||
/* Don't insert, duplicate if flag not set. */ \
|
/* Don't insert, duplicate if flag not set. */ \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
/* We must preserve nodes that will be mutated when we are \
|
/* Snapshots preserve those nodes in the `path` that are will be \
|
||||||
maintaining a snapshot. */ \
|
modified on insert. */ \
|
||||||
if (slist->slh_snap.pres != NULL) { \
|
if (slist->slh_snap.pres != NULL) { \
|
||||||
__skip_preserve_node_##decl(slist, node, NULL); \
|
__skip_preserve_##decl(slist, path, len); \
|
||||||
} \
|
} \
|
||||||
/* Record the generation for this node to enable snapshots. */ \
|
/* Record the generation for this node to enable snapshots. */ \
|
||||||
new->field.sle_gen = __skip_snapshot_gen_##decl(); \
|
new->field.sle_gen = __skip_snapshot_gen_##decl(); \
|
||||||
|
@ -1105,7 +1106,6 @@ __skip_read_rdtsc(void)
|
||||||
{ \
|
{ \
|
||||||
static decl##_node_t apath[SKIPLIST_MAX_HEIGHT + 1]; \
|
static decl##_node_t apath[SKIPLIST_MAX_HEIGHT + 1]; \
|
||||||
int rc = 0; \
|
int rc = 0; \
|
||||||
size_t len; \
|
|
||||||
decl##_node_t *node, **path = (decl##_node_t **)&apath; \
|
decl##_node_t *node, **path = (decl##_node_t **)&apath; \
|
||||||
\
|
\
|
||||||
if (slist == NULL) \
|
if (slist == NULL) \
|
||||||
|
@ -1119,7 +1119,7 @@ __skip_read_rdtsc(void)
|
||||||
} \
|
} \
|
||||||
memset(path, 0, sizeof(decl##_node_t *) * slist->slh_max + 1); \
|
memset(path, 0, sizeof(decl##_node_t *) * slist->slh_max + 1); \
|
||||||
\
|
\
|
||||||
len = __skip_locate_##decl(slist, new, path); \
|
__skip_locate_##decl(slist, new, path); \
|
||||||
node = path[0]; \
|
node = path[0]; \
|
||||||
\
|
\
|
||||||
if (SKIPLIST_MAX_HEIGHT == 1) \
|
if (SKIPLIST_MAX_HEIGHT == 1) \
|
||||||
|
@ -1141,7 +1141,7 @@ __skip_read_rdtsc(void)
|
||||||
*/ \
|
*/ \
|
||||||
int prefix##skip_remove_node_##decl(decl##_t *slist, decl##_node_t *n) \
|
int prefix##skip_remove_node_##decl(decl##_t *slist, decl##_node_t *n) \
|
||||||
{ \
|
{ \
|
||||||
size_t i, len, height; \
|
size_t i, len, np = 0, height; \
|
||||||
static decl##_node_t apath[SKIPLIST_MAX_HEIGHT + 1]; \
|
static decl##_node_t apath[SKIPLIST_MAX_HEIGHT + 1]; \
|
||||||
decl##_node_t *node, **path = (decl##_node_t **)&apath; \
|
decl##_node_t *node, **path = (decl##_node_t **)&apath; \
|
||||||
\
|
\
|
||||||
|
@ -1162,6 +1162,12 @@ __skip_read_rdtsc(void)
|
||||||
len = __skip_locate_##decl(slist, n, path); \
|
len = __skip_locate_##decl(slist, n, path); \
|
||||||
node = path[0]; \
|
node = path[0]; \
|
||||||
if (node) { \
|
if (node) { \
|
||||||
|
/* Preserve this node about to be removed. */ \
|
||||||
|
if (slist->slh_snap.pres != NULL) { \
|
||||||
|
np = __skip_preserve_node_##decl(slist, node, NULL); \
|
||||||
|
if (np > 0) \
|
||||||
|
return np; \
|
||||||
|
} \
|
||||||
/* We found it, set the next->prev to the node->prev keeping in mind \
|
/* We found it, set the next->prev to the node->prev keeping in mind \
|
||||||
that the next node might be the tail). */ \
|
that the next node might be the tail). */ \
|
||||||
node->field.sle_next[0]->field.sle_prev = node->field.sle_prev; \
|
node->field.sle_next[0]->field.sle_prev = node->field.sle_prev; \
|
||||||
|
@ -1187,6 +1193,8 @@ __skip_read_rdtsc(void)
|
||||||
if (SKIPLIST_MAX_HEIGHT == 1) \
|
if (SKIPLIST_MAX_HEIGHT == 1) \
|
||||||
free(path); \
|
free(path); \
|
||||||
\
|
\
|
||||||
|
/* If we didn't preserve any nodes we can free this one. */ \
|
||||||
|
if (np == 0) \
|
||||||
free_node_blk; \
|
free_node_blk; \
|
||||||
\
|
\
|
||||||
/* Reduce the height of the header. */ \
|
/* Reduce the height of the header. */ \
|
||||||
|
|
Loading…
Reference in a new issue