rculfhash: flip order of removal
[urcu.git] / urcu / rculfhash.h
CommitLineData
a42cc659
MD
1#ifndef _URCU_RCULFHASH_H
2#define _URCU_RCULFHASH_H
ab7d5fc6 3
674f7a69 4#include <stdint.h>
abc490a1
MD
5#include <urcu-call-rcu.h>
6
7struct rcu_ht_node {
8 struct rcu_ht_node *next;
9 void *key;
732ad076 10 size_t key_len;
abc490a1
MD
11 unsigned long hash;
12 unsigned long reverse_hash;
13 unsigned int dummy;
abc490a1
MD
14 struct rcu_head head;
15};
16
17struct rcu_ht;
ab7d5fc6 18
5e28c532
MD
19/*
20 * Caution !
abc490a1 21 * Ensure reader and writer threads are registered as urcu readers.
5e28c532
MD
22 */
23
732ad076
MD
24typedef unsigned long (*ht_hash_fct)(void *key, size_t length,
25 unsigned long seed);
26typedef unsigned long (*ht_compare_fct)(void *key1, size_t key1_len,
27 void *key2, size_t key2_len);
abc490a1
MD
28
29static inline
732ad076 30void ht_node_init(struct rcu_ht_node *node, void *key,
cb233752 31 size_t key_len)
abc490a1
MD
32{
33 node->key = key;
732ad076 34 node->key_len = key_len;
abc490a1
MD
35 node->dummy = 0;
36}
674f7a69
MD
37
38/*
39 * init_size must be power of two.
40 */
abc490a1 41struct rcu_ht *ht_new(ht_hash_fct hash_fct,
732ad076
MD
42 ht_compare_fct compare_fct,
43 unsigned long hash_seed,
abc490a1
MD
44 unsigned long init_size,
45 void (*ht_call_rcu)(struct rcu_head *head,
46 void (*func)(struct rcu_head *head)));
ab7d5fc6 47
5e28c532 48int ht_destroy(struct rcu_ht *ht);
ab7d5fc6 49
abc490a1 50/* Call with rcu_read_lock held. */
732ad076 51struct rcu_ht_node *ht_lookup(struct rcu_ht *ht, void *key, size_t key_len);
ab7d5fc6 52
abc490a1 53/* Call with rcu_read_lock held. */
f000907d 54void ht_add(struct rcu_ht *ht, struct rcu_ht_node *node);
ab7d5fc6 55
3eca1b8c
MD
56/* Call with rcu_read_lock held. */
57int ht_add_unique(struct rcu_ht *ht, struct rcu_ht_node *node);
58
abc490a1
MD
59/* Call with rcu_read_lock held. */
60int ht_remove(struct rcu_ht *ht, struct rcu_ht_node *node);
ab7d5fc6 61
464a1ec9
MD
62void ht_resize(struct rcu_ht *ht, int growth);
63
a42cc659 64#endif /* _URCU_RCULFHASH_H */
This page took 0.035956 seconds and 4 git commands to generate.