@@ -94,7 +94,7 @@ public actual open class LockFreeLinkedListNode {
94
94
// prev.next correction, which does not provide linearizable backwards iteration, but can be used to
95
95
// resume forward iteration when current node was removed.
96
96
public actual val prevNode: Node
97
- get() = correctPrev(null ) ? : findPrevNonRemoved(_prev .value)
97
+ get() = correctPrev() ? : findPrevNonRemoved(_prev .value)
98
98
99
99
private tailrec fun findPrevNonRemoved (current : Node ): Node {
100
100
if (! current.isRemoved) return current
@@ -210,7 +210,7 @@ public actual open class LockFreeLinkedListNode {
210
210
val removed = (next as Node ).removed()
211
211
if (_next .compareAndSet(next, removed)) {
212
212
// was removed successfully (linearized remove) -- fixup the list
213
- next.correctPrev(null )
213
+ next.correctPrev()
214
214
return null
215
215
}
216
216
}
@@ -250,7 +250,7 @@ public actual open class LockFreeLinkedListNode {
250
250
if (next._prev .compareAndSet(nextPrev, this )) {
251
251
// This newly added node could have been removed, and the above CAS would have added it physically again.
252
252
// Let us double-check for this situation and correct if needed
253
- if (isRemoved) next.correctPrev(null )
253
+ if (isRemoved) next.correctPrev()
254
254
return
255
255
}
256
256
}
@@ -268,7 +268,7 @@ public actual open class LockFreeLinkedListNode {
268
268
* remover of this node will ultimately call [correctPrev] on the next node and that will fix all
269
269
* the links from this node, too.
270
270
*/
271
- private tailrec fun correctPrev (op : OpDescriptor ? ): Node ? {
271
+ private tailrec fun correctPrev (): Node ? {
272
272
val oldPrev = _prev .value
273
273
var prev: Node = oldPrev
274
274
var last: Node ? = null // will be set so that last.next === prev
@@ -281,22 +281,21 @@ public actual open class LockFreeLinkedListNode {
281
281
// otherwise need to update prev
282
282
if (! this ._prev .compareAndSet(oldPrev, prev)) {
283
283
// Note: retry from scratch on failure to update prev
284
- return correctPrev(op )
284
+ return correctPrev()
285
285
}
286
286
return prev // return the correct prev
287
287
}
288
288
// slow path when we need to help remove operations
289
289
this .isRemoved -> return null // nothing to do, this node was removed, bail out asap to save time
290
- prevNext == = op -> return prev // part of the same op -- don't recurse, didn't correct prev
291
290
prevNext is OpDescriptor -> { // help & retry
292
291
prevNext.perform(prev)
293
- return correctPrev(op ) // retry from scratch
292
+ return correctPrev() // retry from scratch
294
293
}
295
294
prevNext is Removed -> {
296
295
if (last != = null ) {
297
296
// newly added (prev) node is already removed, correct last.next around it
298
297
if (! last._next .compareAndSet(prev, prevNext.ref)) {
299
- return correctPrev(op ) // retry from scratch on failure to update next
298
+ return correctPrev() // retry from scratch on failure to update next
300
299
}
301
300
prev = last
302
301
last = null
0 commit comments