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