1 #ifndef _URCU_RCULFHASH_H
2 #define _URCU_RCULFHASH_H
5 #include <urcu-call-rcu.h>
8 /* cache-hot for iteration */
9 struct rcu_ht_node
*next
;
10 unsigned long reverse_hash
;
14 /* cache-cold for iteration */
23 * Ensure reader and writer threads are registered as urcu readers.
26 typedef unsigned long (*ht_hash_fct
)(void *key
, size_t length
,
28 typedef unsigned long (*ht_compare_fct
)(void *key1
, size_t key1_len
,
29 void *key2
, size_t key2_len
);
32 void ht_node_init(struct rcu_ht_node
*node
, void *key
,
36 node
->key_len
= key_len
;
41 * init_size must be power of two.
43 struct rcu_ht
*ht_new(ht_hash_fct hash_fct
,
44 ht_compare_fct compare_fct
,
45 unsigned long hash_seed
,
46 unsigned long init_size
,
47 void (*ht_call_rcu
)(struct rcu_head
*head
,
48 void (*func
)(struct rcu_head
*head
)));
50 int ht_destroy(struct rcu_ht
*ht
);
51 /* Count the number of nodes in the hash table. Call with rcu_read_lock held. */
52 void ht_count_nodes(struct rcu_ht
*ht
,
54 unsigned long *removed
);
56 /* Call with rcu_read_lock held. */
57 struct rcu_ht_node
*ht_lookup(struct rcu_ht
*ht
, void *key
, size_t key_len
);
59 /* Call with rcu_read_lock held. */
60 void ht_add(struct rcu_ht
*ht
, struct rcu_ht_node
*node
);
62 /* Call with rcu_read_lock held. */
63 int ht_add_unique(struct rcu_ht
*ht
, struct rcu_ht_node
*node
);
65 /* Call with rcu_read_lock held. */
66 int ht_remove(struct rcu_ht
*ht
, struct rcu_ht_node
*node
);
68 void ht_resize(struct rcu_ht
*ht
, int growth
);
70 #endif /* _URCU_RCULFHASH_H */