struct rcu_head rcu_head; /* For call_rcu() */
};
+static
int match(struct cds_lfht_node *ht_node, const void *_key)
{
struct mynode *node =
return *key == node->value;
}
+static
+void free_node(struct rcu_head *head)
+{
+ struct mynode *node = caa_container_of(head, struct mynode, rcu_head);
+
+ free(node);
+}
+
int main(int argc, char **argv)
{
int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */
ret = cds_lfht_del(ht, ht_node);
if (ret) {
printf(" (concurrently deleted)");
+ } else {
+ struct mynode *del_node =
+ caa_container_of(ht_node,
+ struct mynode, node);
+ call_rcu(&del_node->rcu_head, free_node);
}
} else {
printf(" (not found)");