- L04 load-acquires the current 'list_p' value into 'mid'; the the use of load-acquire is necessary to get the latest value release-stored by another thread; the current 'list_p' is updated by either a release-store or a cmpxchg'ed by another thread depending on the algorithm that made the update; only the release-store needs to match up with a load-acquire, but this code doesn't know whether release-store or cmpxchg was used.
- L0 is the empty list check and the only time that false is returned by this function.
- L08 tries to mark the next field in 'mid':
- If marking is not successful, we loop around to try it all again.
- If marking is successful, then 'next_p' contains mid's unmarked next field value.
- L09 load-acquires the current 'list_p' value to see if it still matches 'mid':
- If the list head has changed, then we unmark mid on L11 and try it all again.
- Otherwise, 'mid' is returned via 'mid_p' and we return true.