1aa98c5618b25da6219e87c0e15ec60dfc2ea2e5
[urcu.git] / urcu / rculfhash.h
1 #ifndef _URCU_RCULFHASH_H
2 #define _URCU_RCULFHASH_H
3
4 #include <stdint.h>
5 #include <urcu-call-rcu.h>
6
7 struct rcu_ht_node {
8 struct rcu_ht_node *next;
9 void *key;
10 unsigned long hash;
11 unsigned long reverse_hash;
12 unsigned int dummy;
13 void *value;
14 struct rcu_head head;
15 };
16
17 struct rcu_ht;
18
19 /*
20 * Caution !
21 * Ensure reader and writer threads are registered as urcu readers.
22 */
23
24 typedef unsigned long (*ht_hash_fct)(void *hashseed, void *key);
25
26 static inline
27 void ht_node_init(struct rcu_ht_node *node, void *key, void *value)
28 {
29 node->key = key;
30 node->value = value;
31 node->dummy = 0;
32 }
33
34 /*
35 * init_size must be power of two.
36 */
37 struct rcu_ht *ht_new(ht_hash_fct hash_fct,
38 void *hashseed,
39 unsigned long init_size,
40 void (*ht_call_rcu)(struct rcu_head *head,
41 void (*func)(struct rcu_head *head)));
42
43 int ht_destroy(struct rcu_ht *ht);
44
45 /* Call with rcu_read_lock held. */
46 struct rcu_ht_node *ht_lookup(struct rcu_ht *ht, void *key);
47
48 /* Call with rcu_read_lock held. */
49 void ht_add(struct rcu_ht *ht, struct rcu_ht_node *node);
50
51 /* Call with rcu_read_lock held. */
52 int ht_remove(struct rcu_ht *ht, struct rcu_ht_node *node);
53
54 void ht_resize(struct rcu_ht *ht, int growth);
55
56 #endif /* _URCU_RCULFHASH_H */
This page took 0.044626 seconds and 4 git commands to generate.