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