rculfhash: introduce cds_lfht_node_init_deleted
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 10 Jan 2022 20:35:53 +0000 (15:35 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 18 Jan 2022 14:56:34 +0000 (09:56 -0500)
Allow initializing lfht node to "removed" state to allow querying
whether the node is published in a hash table before it is added to the
hash table and after it has been removed from the hash table.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I6e364a3ea076f33e34b4c63c7b23be22b35e9bb1

include/urcu/rculfhash.h
src/rculfhash.c

index 29dd88f1f16b0ea320ffa82ef2ed0596c7aaba65..8586e1da371f86e2c19518f60a8cef69e6db691e 100644 (file)
@@ -109,6 +109,16 @@ void cds_lfht_node_init(struct cds_lfht_node *node __attribute__((unused)))
 {
 }
 
+/*
+ * cds_lfht_node_init_deleted - initialize a hash table node to "removed" state
+ * @node: the node to initialize.
+ *
+ * Initialize the node such that cds_lfht_is_node_deleted() can be used
+ * on the node before it is added to a hash table.
+ */
+extern
+void cds_lfht_node_init_deleted(struct cds_lfht_node *node);
+
 /*
  * Hash table creation flags.
  */
index 04fd49946aa940184015a4921971feff5d3818e5..8046f3a63a280397be3986231f1db8921ea4bfdb 100644 (file)
@@ -851,6 +851,12 @@ int is_removal_owner(struct cds_lfht_node *node)
        return ((unsigned long) node) & REMOVAL_OWNER_FLAG;
 }
 
+static
+struct cds_lfht_node *flag_removed(struct cds_lfht_node *node)
+{
+       return (struct cds_lfht_node *) (((unsigned long) node) | REMOVED_FLAG);
+}
+
 static
 struct cds_lfht_node *flag_removal_owner(struct cds_lfht_node *node)
 {
@@ -1578,6 +1584,12 @@ const struct cds_lfht_mm_type *get_mm_type(
 }
 #endif
 
+void cds_lfht_node_init_deleted(struct cds_lfht_node *node)
+{
+       cds_lfht_node_init(node);
+       node->next = flag_removed(NULL);
+}
+
 struct cds_lfht *_cds_lfht_new(unsigned long init_size,
                        unsigned long min_nr_alloc_buckets,
                        unsigned long max_nr_buckets,
This page took 0.026683 seconds and 4 git commands to generate.