+// SPDX-FileCopyrightText: 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+// SPDX-FileCopyrightText: 2011 Lai Jiangshan <laijs@cn.fujitsu.com>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
#ifndef _URCU_RCULFHASH_INTERNAL_H
#define _URCU_RCULFHASH_INTERNAL_H
/*
- * urcu/rculfhash-internal.h
- *
* Internal header for Lock-Free RCU Hash Table
- *
- * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- * Copyright 2011 - Lai Jiangshan <laijs@cn.fujitsu.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <urcu/assert.h>
#include <urcu/rculfhash.h>
#include <stdio.h>
#include <stdlib.h>
-#include <assert.h>
+
+#include "workqueue.h"
#ifdef DEBUG
#define dbg_printf(fmt, args...) printf("[debug rculfhash] " fmt, ## args)
/* Initial configuration items */
unsigned long max_nr_buckets;
const struct cds_lfht_mm_type *mm; /* memory management plugin */
+ const struct cds_lfht_alloc *alloc; /* memory allocator for mm */
const struct rcu_flavor_struct *flavor; /* RCU flavor */
long count; /* global approximate item count */
* therefore cause grace-period deadlock if we hold off RCU G.P.
* completion.
*/
- pthread_mutex_t resize_mutex; /* resize mutex: add/del mutex */
- pthread_attr_t *resize_attr; /* Resize threads attributes */
+ pthread_mutex_t resize_mutex; /* resize mutex: add/del mutex */
+ pthread_attr_t *caller_resize_attr; /* resize threads attributes from lfht_new caller */
+ pthread_attr_t resize_attr;
unsigned int in_progress_destroy;
unsigned long resize_target;
int resize_initiated;
+ struct urcu_work destroy_work;
/*
* Variables needed for add and remove fast-paths.
extern int cds_lfht_get_count_order_ulong(unsigned long x);
#ifdef POISON_FREE
-#define poison_free(ptr) \
+#define poison_free(alloc, ptr) \
do { \
if (ptr) { \
memset(ptr, 0x42, sizeof(*(ptr))); \
- free(ptr); \
+ alloc->free(alloc->state, ptr); \
} \
} while (0)
#else
-#define poison_free(ptr) free(ptr)
+#define poison_free(alloc, ptr) alloc->free(alloc->state, ptr)
#endif
static inline
struct cds_lfht *__default_alloc_cds_lfht(
const struct cds_lfht_mm_type *mm,
+ const struct cds_lfht_alloc *alloc,
unsigned long cds_lfht_size,
unsigned long min_nr_alloc_buckets,
unsigned long max_nr_buckets)
{
struct cds_lfht *ht;
- ht = calloc(1, cds_lfht_size);
- assert(ht);
+ ht = alloc->calloc(alloc->state, 1, cds_lfht_size);
+ urcu_posix_assert(ht);
ht->mm = mm;
+ ht->alloc = alloc;
ht->bucket_at = mm->bucket_at;
ht->min_nr_alloc_buckets = min_nr_alloc_buckets;
ht->min_alloc_buckets_order =