split-ordered hash table
[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;
10 unsigned long hash;
11 unsigned long reverse_hash;
12 unsigned int dummy;
13 void *value;
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
abc490a1
MD
24typedef unsigned long (*ht_hash_fct)(void *hashseed, void *key);
25
26static inline
27void 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}
674f7a69
MD
33
34/*
35 * init_size must be power of two.
36 */
abc490a1
MD
37struct 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)));
ab7d5fc6 42
5e28c532 43int ht_destroy(struct rcu_ht *ht);
ab7d5fc6 44
abc490a1
MD
45/* Call with rcu_read_lock held. */
46struct rcu_ht_node *ht_lookup(struct rcu_ht *ht, void *key);
ab7d5fc6 47
abc490a1
MD
48/* Call with rcu_read_lock held. */
49int ht_add(struct rcu_ht *ht, struct rcu_ht_node *node);
ab7d5fc6 50
abc490a1
MD
51/* Call with rcu_read_lock held. */
52int ht_remove(struct rcu_ht *ht, struct rcu_ht_node *node);
ab7d5fc6 53
464a1ec9
MD
54void ht_resize(struct rcu_ht *ht, int growth);
55
a42cc659 56#endif /* _URCU_RCULFHASH_H */
This page took 0.033734 seconds and 4 git commands to generate.