X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=doc%2Fexamples%2Frculfhash%2Fcds_lfht_add_replace.c;h=19c372675706d9ea7c74775480cd1574d5cdbb50;hp=62de40c033f97feca95c25b456c4bb1caa16714d;hb=b9050d917ab84db192b5609ba6dd9973a82d215a;hpb=042e8cfe9b352b325a7350f345a3f2923606a2be diff --git a/doc/examples/rculfhash/cds_lfht_add_replace.c b/doc/examples/rculfhash/cds_lfht_add_replace.c index 62de40c..19c3726 100644 --- a/doc/examples/rculfhash/cds_lfht_add_replace.c +++ b/doc/examples/rculfhash/cds_lfht_add_replace.c @@ -21,7 +21,7 @@ #include #include -#include /* RCU flavor */ +#include /* RCU flavor */ #include /* RCU Lock-free hash table */ #include /* For CAA_ARRAY_SIZE */ #include "jhash.h" /* Example hash function */ @@ -69,7 +69,7 @@ int main(int argc, char **argv) * Each thread need using RCU read-side need to be explicitly * registered. */ - rcu_register_thread(); + urcu_memb_register_thread(); /* Use time as seed for hash table hashing. */ seed = (uint32_t) time(NULL); @@ -77,9 +77,9 @@ int main(int argc, char **argv) /* * Allocate hash table. */ - ht = cds_lfht_new(1, 1, 0, + ht = cds_lfht_new_flavor(1, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, - NULL); + &urcu_memb_flavor, NULL); if (!ht) { printf("Error allocating hash table\n"); ret = -1; @@ -109,7 +109,7 @@ int main(int argc, char **argv) * cds_lfht_add() needs to be called from RCU read-side * critical section. */ - rcu_read_lock(); + urcu_memb_read_lock(); ht_node = cds_lfht_add_replace(ht, hash, match, &value, &node->node); if (ht_node) { @@ -119,12 +119,12 @@ int main(int argc, char **argv) printf("Replaced node (key: %d, seqnum: %d) by (key: %d, seqnum: %d)\n", ret_node->value, ret_node->seqnum, node->value, node->seqnum); - call_rcu(&ret_node->rcu_head, free_node); + urcu_memb_call_rcu(&ret_node->rcu_head, free_node); } else { printf("Add (key: %d, seqnum: %d)\n", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -133,15 +133,15 @@ int main(int argc, char **argv) * be performed within RCU read-side critical section. */ printf("hash table content (random order):"); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry(ht, &iter, node, node) { printf(" (key: %d, seqnum: %d)", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); printf("\n"); end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; }