X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Frculfhash.h;h=1376b5a0b4e2b4fb0fe70378f9bc91644a845027;hp=860ef3d1c2d05e3516ec4a8849c9d47b39f1371f;hb=3df0c49cf3184147c21ed8257ac65aaba9ffca2a;hpb=14b2b8b8b23d8bf89411ed532cbf9011041981c6 diff --git a/urcu/rculfhash.h b/urcu/rculfhash.h index 860ef3d..1376b5a 100644 --- a/urcu/rculfhash.h +++ b/urcu/rculfhash.h @@ -42,6 +42,11 @@ struct _cds_lfht_node { unsigned long reverse_hash; } __attribute__((aligned(4))); +/* + * struct cds_lfht_node can be embedded into a structure (as a field). + * caa_container_of() can be used to get the structure from the struct + * cds_lfht_node after a lookup. + */ struct cds_lfht_node { /* cache-hot for iteration */ struct _cds_lfht_node p; /* needs to be first field */ @@ -131,6 +136,7 @@ struct cds_lfht *_cds_lfht_new(cds_lfht_hash_fct hash_fct, * this priority level. Having lower priority for call_rcu and resize threads * does not pose any correctness issue, but the resize operations could be * starved by updates, thus leading to long hash table bucket chains. + * Threads calling this API need to be registered RCU read-side threads. */ static inline struct cds_lfht *cds_lfht_new(cds_lfht_hash_fct hash_fct, @@ -156,6 +162,7 @@ struct cds_lfht *cds_lfht_new(cds_lfht_hash_fct hash_fct, * allocated. * * Return 0 on success, negative error value on error. + * Threads calling this API need to be registered RCU read-side threads. */ int cds_lfht_destroy(struct cds_lfht *ht, pthread_attr_t **attr); @@ -163,6 +170,7 @@ int cds_lfht_destroy(struct cds_lfht *ht, pthread_attr_t **attr); * cds_lfht_count_nodes - count the number of nodes in the hash table. * * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. */ void cds_lfht_count_nodes(struct cds_lfht *ht, long *approx_before, @@ -175,12 +183,13 @@ void cds_lfht_count_nodes(struct cds_lfht *ht, * * Output in "*iter". *iter->node set to NULL if not found. * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. */ void cds_lfht_lookup(struct cds_lfht *ht, void *key, size_t key_len, struct cds_lfht_iter *iter); /* - * cds_lfht_next - get the next item with same key (after a lookup). + * cds_lfht_next_duplicate - get the next item with same key (after a lookup). * * Uses an iterator initialized by a lookup. * Sets *iter-node to the following node with same key. @@ -189,14 +198,35 @@ void cds_lfht_lookup(struct cds_lfht *ht, void *key, size_t key_len, * cds_lfht_next calls, and also between cds_lfht_next calls using the * node returned by a previous cds_lfht_next. * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + */ +void cds_lfht_next_duplicate(struct cds_lfht *ht, struct cds_lfht_iter *iter); + +/* + * cds_lfht_first - get the first node in the table. + * + * Output in "*iter". *iter->node set to NULL if table is empty. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. + */ +void cds_lfht_first(struct cds_lfht *ht, struct cds_lfht_iter *iter); + +/* + * cds_lfht_next - get the next node in the table. + * + * Input/Output in "*iter". *iter->node set to NULL if *iter was + * pointing to the last table node. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. */ void cds_lfht_next(struct cds_lfht *ht, struct cds_lfht_iter *iter); /* * cds_lfht_add - add a node to the hash table. * - * Call with rcu_read_lock held. * This function supports adding redundant keys into the table. + * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. */ void cds_lfht_add(struct cds_lfht *ht, struct cds_lfht_node *node); @@ -208,6 +238,7 @@ void cds_lfht_add(struct cds_lfht *ht, struct cds_lfht_node *node); * cds_lfht_add_unique fails, the node passed as parameter should be * freed by the caller. * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. * * The semantic of this function is that if only this function is used * to add keys into the table, no duplicated keys should ever be @@ -224,6 +255,7 @@ struct cds_lfht_node *cds_lfht_add_unique(struct cds_lfht *ht, * was present, return NULL, which also means the operation succeeded. * This replacement operation should never fail. * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. * After successful replacement, a grace period must be waited for before * freeing the memory reserved for the returned node. * @@ -249,6 +281,7 @@ struct cds_lfht_node *cds_lfht_add_replace(struct cds_lfht *ht, * Old node can be looked up with cds_lfht_lookup and cds_lfht_next. * RCU read-side lock must be held between lookup and replacement. * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. * After successful replacement, a grace period must be waited for before * freeing the memory reserved for the old node (which can be accessed * with cds_lfht_iter_get_node). @@ -277,6 +310,7 @@ int cds_lfht_replace(struct cds_lfht *ht, struct cds_lfht_iter *old_iter, * cds_lfht_iter_get_node. * RCU read-side lock must be held between lookup and removal. * Call with rcu_read_lock held. + * Threads calling this API need to be registered RCU read-side threads. * After successful removal, a grace period must be waited for before * freeing the memory reserved for old node (which can be accessed with * cds_lfht_iter_get_node). @@ -286,6 +320,8 @@ int cds_lfht_del(struct cds_lfht *ht, struct cds_lfht_iter *iter); /* * cds_lfht_resize - Force a hash table resize * @new_size: update to this hash table size. + * + * Threads calling this API need to be registered RCU read-side threads. */ void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size);