+static
+void *partition_resize_thread(void *arg)
+{
+ struct partition_resize_work *work = arg;
+
+ work->ht->cds_lfht_rcu_register_thread();
+ work->fct(work->ht, work->i, work->start, work->len);
+ work->ht->cds_lfht_rcu_unregister_thread();
+ return NULL;
+}
+
+static
+void partition_resize_helper(struct cds_lfht *ht, unsigned long i,
+ unsigned long len,
+ void (*fct)(struct cds_lfht *ht, unsigned long i,
+ unsigned long start, unsigned long len))
+{
+ unsigned long partition_len;
+ struct partition_resize_work *work;
+ int cpu, ret;
+ pthread_t *thread_id;
+
+ /* Note: nr_cpus_mask + 1 is always power of 2 */
+ partition_len = len >> get_count_order_ulong(nr_cpus_mask + 1);
+ work = calloc(nr_cpus_mask + 1, sizeof(*work));
+ thread_id = calloc(nr_cpus_mask + 1, sizeof(*thread_id));
+ assert(work);
+ for (cpu = 0; cpu < nr_cpus_mask + 1; cpu++) {
+ work[cpu].ht = ht;
+ work[cpu].i = i;
+ work[cpu].len = partition_len;
+ work[cpu].start = cpu * partition_len;
+ work[cpu].fct = fct;
+ ret = pthread_create(&thread_id[cpu], ht->resize_attr,
+ partition_resize_thread, &work[cpu]);
+ assert(!ret);
+ }
+ for (cpu = 0; cpu < nr_cpus_mask + 1; cpu++) {
+ ret = pthread_join(thread_id[cpu], NULL);
+ assert(!ret);
+ }
+ free(work);
+ free(thread_id);
+}
+