#include "common.h"
#include "mlocal.h"
+#include "list.h"
#include "mem.h"
typedef struct node {
return DOES_NOT_EXIST;
}
- // Mark <item> removed. This must be atomic. If multiple threads try to remove the same item
- // only one of them should succeed.
+ // Mark <item> removed. If multiple threads try to remove the same item only one of them should succeed.
node_t *next;
node_t *old_next = item->next;
do {
TRACE("l2", "ll_remove: logically removed item %p", item, 0);
ASSERT(IS_TAGGED(item->next));
- // This has to be an atomic swap in case another thread is updating the item while we are removing it.
+ // Atomically swap out the item's value in case another thread is updating the item while we are
+ // removing it. This establishes which operation occurs first logically, the update or the remove.
uint64_t val = SYNC_SWAP(&item->val, DOES_NOT_EXIST);
TRACE("l2", "ll_remove: replaced item's val %p with DOES_NOT_EXIT", val, 0);