X-Git-Url: https://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=doc%2Fexamples%2Frculfhash%2Fcds_lfht_for_each_entry_duplicate.c;h=a975128f5be28397af4348206e94255fc754e05b;hp=e57509dc44ce2b8008c8e7df12449e802502d158;hb=83e334d03eaba62df373cf44298616458900078a;hpb=b5e35d2dfb026d7f06eec10b3d4794646680429f diff --git a/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c b/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c index e57509d..a975128 100644 --- a/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c +++ b/doc/examples/rculfhash/cds_lfht_for_each_entry_duplicate.c @@ -18,7 +18,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 */ @@ -37,7 +37,7 @@ int match(struct cds_lfht_node *ht_node, const void *_key) { struct mynode *node = caa_container_of(ht_node, struct mynode, node); - const unsigned int *key = _key; + const int *key = _key; return *key == node->value; } @@ -57,7 +57,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); @@ -65,9 +65,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; @@ -97,11 +97,11 @@ 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(); cds_lfht_add(ht, hash, &node->node); printf("Add (key: %d, seqnum: %d)\n", node->value, node->seqnum); - rcu_read_unlock(); + urcu_memb_read_unlock(); } /* @@ -110,12 +110,12 @@ 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"); /* @@ -128,16 +128,16 @@ int main(int argc, char **argv) unsigned long hash = jhash(&value, sizeof(value), seed); printf("lookup key: %d\n", value); - rcu_read_lock(); + urcu_memb_read_lock(); cds_lfht_for_each_entry_duplicate(ht, hash, match, &value, &iter, node, node) { printf(" (key %d, seqnum %d) found\n", node->value, node->seqnum); } - rcu_read_unlock(); + urcu_memb_read_unlock(); } end: - rcu_unregister_thread(); + urcu_memb_unregister_thread(); return ret; }