projects
/
userspace-rcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: futex.h: include headers outside extern C
[userspace-rcu.git]
/
doc
/
examples
/
rculfhash
/
cds_lfht_destroy.c
diff --git
a/doc/examples/rculfhash/cds_lfht_destroy.c
b/doc/examples/rculfhash/cds_lfht_destroy.c
index d82d81c157858e55a879098a0893d5b2147aa1ff..56b9df65359f903759df99ad87e77c9aa5bc93e0 100644
(file)
--- a/
doc/examples/rculfhash/cds_lfht_destroy.c
+++ b/
doc/examples/rculfhash/cds_lfht_destroy.c
@@
-19,7
+19,7
@@
#include <stdlib.h>
#include <time.h>
#include <stdlib.h>
#include <time.h>
-#include <urcu
.h>
/* RCU flavor */
+#include <urcu
/urcu-memb.h>
/* RCU flavor */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
#include <urcu/rculfhash.h> /* RCU Lock-free hash table */
#include <urcu/compiler.h> /* For CAA_ARRAY_SIZE */
#include "jhash.h" /* Example hash function */
@@
-41,7
+41,7
@@
void free_node(struct rcu_head *head)
free(node);
}
free(node);
}
-int main(
int argc, char **argv
)
+int main(
void
)
{
int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */
struct cds_lfht *ht; /* Hash table */
{
int values[] = { -5, 42, 42, 36, 24, }; /* 42 is duplicated */
struct cds_lfht *ht; /* Hash table */
@@
-56,7
+56,7
@@
int main(int argc, char **argv)
* Each thread need using RCU read-side need to be explicitly
* registered.
*/
* 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);
/* Use time as seed for hash table hashing. */
seed = (uint32_t) time(NULL);
@@
-64,9
+64,9
@@
int main(int argc, char **argv)
/*
* Allocate hash table.
*/
/*
* 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,
CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING,
- NULL);
+
&urcu_memb_flavor,
NULL);
if (!ht) {
printf("Error allocating hash table\n");
ret = -1;
if (!ht) {
printf("Error allocating hash table\n");
ret = -1;
@@
-95,9
+95,9
@@
int main(int argc, char **argv)
* cds_lfht_add() needs to be called from RCU read-side
* critical section.
*/
* 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);
cds_lfht_add(ht, hash, &node->node);
-
rcu
_read_unlock();
+
urcu_memb
_read_unlock();
}
/*
}
/*
@@
-106,11
+106,11
@@
int main(int argc, char **argv)
* be performed within RCU read-side critical section.
*/
printf("hash table content (random order):");
* 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(" %d", node->value);
}
cds_lfht_for_each_entry(ht, &iter, node, node) {
printf(" %d", node->value);
}
-
rcu
_read_unlock();
+
urcu_memb
_read_unlock();
printf("\n");
printf("\n");
@@
-118,7
+118,7
@@
int main(int argc, char **argv)
* Make sure all hash table nodes are removed before destroying.
*/
printf("removing all nodes:");
* Make sure all hash table nodes are removed before destroying.
*/
printf("removing all nodes:");
-
rcu
_read_lock();
+
urcu_memb
_read_lock();
cds_lfht_for_each_entry(ht, &iter, node, node) {
ht_node = cds_lfht_iter_get_node(&iter);
ret = cds_lfht_del(ht, ht_node);
cds_lfht_for_each_entry(ht, &iter, node, node) {
ht_node = cds_lfht_iter_get_node(&iter);
ret = cds_lfht_del(ht, ht_node);
@@
-126,10
+126,10
@@
int main(int argc, char **argv)
if (ret) {
printf(" (concurrently deleted)");
} else {
if (ret) {
printf(" (concurrently deleted)");
} else {
- call_rcu(&node->rcu_head, free_node);
+
urcu_memb_
call_rcu(&node->rcu_head, free_node);
}
}
}
}
-
rcu
_read_unlock();
+
urcu_memb
_read_unlock();
printf("\n");
/*
printf("\n");
/*
@@
-144,6
+144,6
@@
int main(int argc, char **argv)
printf("Destroying hash table failed\n");
}
end:
printf("Destroying hash table failed\n");
}
end:
-
rcu
_unregister_thread();
+
urcu_memb
_unregister_thread();
return ret;
}
return ret;
}
This page took
0.025409 seconds
and
4
git commands to generate.