/*
* _cds_lfht_new - API used by cds_lfht_new wrapper. Do not use directly.
*/
+extern
struct cds_lfht *_cds_lfht_new(unsigned long init_size,
unsigned long min_nr_alloc_buckets,
unsigned long max_nr_buckets,
* @min_nr_alloc_buckets: the minimum number of allocated buckets.
* (must be power of two)
* @max_nr_buckets: the maximum number of hash table buckets allowed.
- * (must be power of two)
+ * (must be power of two, 0 is accepted, means
+ * "infinite")
* @flags: hash table creation flags (can be combined with bitwise or: '|').
* 0: no flags.
* CDS_LFHT_AUTO_RESIZE: automatically resize hash table.
* Return 0 on success, negative error value on error.
* Threads calling this API need to be registered RCU read-side threads.
* cds_lfht_destroy should *not* be called from a RCU read-side critical
- * section.
+ * section. It should *not* be called from a call_rcu thread context
+ * neither.
*/
+extern
int cds_lfht_destroy(struct cds_lfht *ht, pthread_attr_t **attr);
/*
* Call with rcu_read_lock held.
* Threads calling this API need to be registered RCU read-side threads.
*/
+extern
void cds_lfht_count_nodes(struct cds_lfht *ht,
long *split_count_before,
unsigned long *count,
* Threads calling this API need to be registered RCU read-side threads.
* This function acts as a rcu_dereference() to read the node pointer.
*/
+extern
void cds_lfht_lookup(struct cds_lfht *ht, unsigned long hash,
cds_lfht_match_fct match, const void *key,
struct cds_lfht_iter *iter);
* Threads calling this API need to be registered RCU read-side threads.
* This function acts as a rcu_dereference() to read the node pointer.
*/
+extern
void cds_lfht_next_duplicate(struct cds_lfht *ht,
cds_lfht_match_fct match, const void *key,
struct cds_lfht_iter *iter);
* Threads calling this API need to be registered RCU read-side threads.
* This function acts as a rcu_dereference() to read the node pointer.
*/
+extern
void cds_lfht_first(struct cds_lfht *ht, struct cds_lfht_iter *iter);
/*
* Threads calling this API need to be registered RCU read-side threads.
* This function acts as a rcu_dereference() to read the node pointer.
*/
+extern
void cds_lfht_next(struct cds_lfht *ht, struct cds_lfht_iter *iter);
/*
* This function issues a full memory barrier before and after its
* atomic commit.
*/
+extern
void cds_lfht_add(struct cds_lfht *ht, unsigned long hash,
struct cds_lfht_node *node);
* Return the unique node already present upon failure. If
* cds_lfht_add_unique fails, the node passed as parameter should be
* freed by the caller. In this case, the caller does NOT need to wait
- * for a grace period before freeing the node.
+ * for a grace period before freeing or re-using the node.
* Call with rcu_read_lock held.
* Threads calling this API need to be registered RCU read-side threads.
*
* node pointer. The failure case does not guarantee any other memory
* barrier.
*/
+extern
struct cds_lfht_node *cds_lfht_add_unique(struct cds_lfht *ht,
unsigned long hash,
cds_lfht_match_fct match,
* 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.
+ * freeing or re-using the memory reserved for the returned node.
*
* The semantic of replacement vs lookups and traversals is the
* following: if lookups and traversals are performed between a key
* This function issues a full memory barrier before and after its
* atomic commit.
*/
+extern
struct cds_lfht_node *cds_lfht_add_replace(struct cds_lfht *ht,
unsigned long hash,
cds_lfht_match_fct match,
* 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).
+ * freeing or re-using the memory reserved for the old node (which can
+ * be accessed with cds_lfht_iter_get_node).
*
* The semantic of replacement vs lookups is the same as
* cds_lfht_add_replace().
* after its atomic commit. Upon failure, this function does not issue
* any memory barrier.
*/
+extern
int cds_lfht_replace(struct cds_lfht *ht,
struct cds_lfht_iter *old_iter,
unsigned long hash,
* 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).
+ * freeing or re-using the memory reserved for old node (which can be
+ * accessed with cds_lfht_iter_get_node).
* Upon success, this function issues a full memory barrier before and
* after its atomic commit. Upon failure, this function does not issue
* any memory barrier.
*/
+extern
int cds_lfht_del(struct cds_lfht *ht, struct cds_lfht_node *node);
/*
* Threads calling this API need to be registered RCU read-side threads.
* This function does not issue any memory barrier.
*/
+extern
int cds_lfht_is_node_deleted(struct cds_lfht_node *node);
/*
*
* Threads calling this API need to be registered RCU read-side threads.
* This function does not (necessarily) issue memory barriers.
+ * cds_lfht_resize should *not* be called from a RCU read-side critical
+ * section.
*/
+extern
void cds_lfht_resize(struct cds_lfht *ht, unsigned long new_size);
/*
for (cds_lfht_first(ht, iter), \
pos = caa_container_of(cds_lfht_iter_get_node(iter), \
__typeof__(*(pos)), member); \
- &(pos)->member != NULL; \
+ cds_lfht_iter_get_node(iter) != NULL; \
cds_lfht_next(ht, iter), \
pos = caa_container_of(cds_lfht_iter_get_node(iter), \
__typeof__(*(pos)), member))
for (cds_lfht_lookup(ht, hash, match, key, iter), \
pos = caa_container_of(cds_lfht_iter_get_node(iter), \
__typeof__(*(pos)), member); \
- &(pos)->member != NULL; \
+ cds_lfht_iter_get_node(iter) != NULL; \
cds_lfht_next_duplicate(ht, match, key, iter), \
pos = caa_container_of(cds_lfht_iter_get_node(iter), \
__typeof__(*(pos)), member))