| 522 | } |
| 523 | |
| 524 | void * |
| 525 | ink_atomiclist_pop(InkAtomicList *l) |
| 526 | { |
| 527 | head_p item; |
| 528 | head_p next; |
| 529 | int result = 0; |
| 530 | do { |
| 531 | INK_QUEUE_LD(item, l->head); |
| 532 | if (TO_PTR(FREELIST_POINTER(item)) == nullptr) { |
| 533 | return nullptr; |
| 534 | } |
| 535 | SET_FREELIST_POINTER_VERSION(next, *ADDRESS_OF_NEXT(TO_PTR(FREELIST_POINTER(item)), l->offset), FREELIST_VERSION(item) + 1); |
| 536 | result = ink_atomic_cas(&l->head.data, item.data, next.data); |
| 537 | } while (result == 0); |
| 538 | { |
| 539 | void *ret = TO_PTR(FREELIST_POINTER(item)); |
| 540 | *ADDRESS_OF_NEXT(ret, l->offset) = nullptr; |
| 541 | return ret; |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | void * |
| 546 | ink_atomiclist_popall(InkAtomicList *l) |