Skip to content

Commit

Permalink
[#204] Bug fix in Blocking Apply functions
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoCastellana committed Mar 29, 2023
1 parent 41e822e commit 3111dba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions include/shad/data_structures/local_multimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class LocalMultimap {
: 1;

typedef KEY_COMPARE KeyCompare;
enum State { EMPTY, USED, PENDING_INSERT };
enum State { EMPTY, USED, PENDING_INSERT, PENDING_UPDATE};

struct Entry {
KTYPE key;
Expand Down Expand Up @@ -1286,8 +1286,11 @@ void LocalMultimap<KTYPE, VTYPE, KEY_COMPARE>::BlockingApply(const KTYPE &key,
// loop
if (KeyComp_(&entry->key, &key) == 0) {
// tagging as pending insert
// while (entry->state == PENDING_INSERT) {
// rt::impl::yield();
// }
while (!__sync_bool_compare_and_swap(&entry->state, USED,
PENDING_INSERT)) {
PENDING_UPDATE)) {
rt::impl::yield();
}
function(key, entry->value, args...);
Expand Down Expand Up @@ -1328,7 +1331,7 @@ void LocalMultimap<KTYPE, VTYPE, KEY_COMPARE>::AsyncBlockingApply(rt::Handle &h,
if (KeyComp_(&entry->key, &key) == 0) {
// tagging as pending insert
while (!__sync_bool_compare_and_swap(&entry->state, USED,
PENDING_INSERT)) {
PENDING_UPDATE)) {
rt::impl::yield();
}
function(h, key, entry->value, args...);
Expand Down

0 comments on commit 3111dba

Please sign in to comment.