rculfhash: fix resize (use log2 of chain length)
[urcu.git] / urcu / rculfhash.h
... / ...
CommitLineData
1#ifndef _URCU_RCULFHASH_H
2#define _URCU_RCULFHASH_H
3
4#include <stdint.h>
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;
18
19/*
20 * Caution !
21 * Ensure reader and writer threads are registered as urcu readers.
22 */
23
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}
33
34/*
35 * init_size must be power of two.
36 */
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)));
42
43int ht_destroy(struct rcu_ht *ht);
44
45/* Call with rcu_read_lock held. */
46struct rcu_ht_node *ht_lookup(struct rcu_ht *ht, void *key);
47
48/* Call with rcu_read_lock held. */
49void ht_add(struct rcu_ht *ht, struct rcu_ht_node *node);
50
51/* Call with rcu_read_lock held. */
52int ht_remove(struct rcu_ht *ht, struct rcu_ht_node *node);
53
54void ht_resize(struct rcu_ht *ht, int growth);
55
56#endif /* _URCU_RCULFHASH_H */
This page took 0.021891 seconds and 4 git commands to generate.