From 6d1c73b7b42a06d827e70b76928c45609eb025fc Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 6 Jan 2021 14:55:56 -0800 Subject: [PATCH] WIP --- ck-polyfill.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ck-polyfill.h b/ck-polyfill.h index f1275503..c4f92b30 100644 --- a/ck-polyfill.h +++ b/ck-polyfill.h @@ -94,16 +94,21 @@ ck_array_commit(ck_array_t *array); // Can we safely lock the array, make a copy, and interate over that???? #define CK_ARRAY_FOREACH(a, i, b) \ - TODO: - pthread_mutex_lock(&(array->lock)); - hashset_remove(array->hs, pointer); - pthread_mutex_unlock(&(array->lock)); -// (i)->snapshot = ck_pr_load_ptr(&(a)->active); -// ck_pr_fence_load(); -// for (unsigned int _ck_i = 0; -// _ck_i < (a)->active->n_committed && -// ((*b) = (a)->active->values[_ck_i], 1); -// _ck_i++) + pthread_mutex_lock(&(a->lock)); + size_t *tmp = calloc(a->hs->nitems, sizeof(struct hashset_st)); + int tmpc = a->hs->nitems; + // TODO: just do this in the loop below, this is unnecessary + for (unsigned int tmpi = 0, tmpii = 0; tmpi < tmpc; tmpi++) { + if (a->hs->items != 0 && a->hs->items != 1) { + tmp[tmpii] = a->hs->items[tmpi]; + tmpii++; + } + } + pthread_mutex_unlock(&(a->lock)); + for (unsigned int _ck_i = 0; + _ck_i < (a)->active->n_committed && + ((*b) = (a)->active->values[_ck_i], 1); + _ck_i++) // CAS section bool