Skip to content

Instantly share code, notes, and snippets.

@pramalhe
Created February 17, 2017 12:18
T* dequeue(void) {
while (true) {
Node* lhead = hp.protectPtr(kHpHead, head.load());
if (lhead != head.load()) continue;
Node* lnext = lhead->next.load();
if (isMark(lnext)) {
if (getUnmark(lnext) == nullptr) return nullptr;
if (casHead(lhead, getUnmark(lnext))) hp.retire(lhead);
continue;
}
if (lhead->casNext(lnext, getMark(lnext))) {
return lhead->item;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment