hi folks, anyone knows why atomicFu raises an erro...
# coroutines
g
hi folks, anyone knows why atomicFu raises an error here:
Copy code
private class Node(
    val job: QueueJob,
    // Pointer to the next node in linked list.
    val next: AtomicRef<Node?> = atomic(null)
) {
    // Checks if this node is the physical tail of the linked list.
    val isTail: Boolean get() = next.value == null
}
Error:
Copy code
Exception in thread "main" java.lang.NoSuchMethodError: 'void asynqueueproblem.Queue$Node.<init>(kotlin.jvm.functions.Function2, kotlinx.atomicfu.AtomicRef, int, kotlin.jvm.internal.DefaultConstructorMarker)'
	at asynqueueproblem.Queue.<init>(Queue.kt:40)
	at asynqueueproblem.Queue.<init>(Queue.kt:13)
	at asynqueueproblem.QueueKt.queueWithInitialValue(Queue.kt:116)
	at asynqueueproblem.MainKt$main$1.invokeSuspend(Main.kt:12)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at asynqueueproblem.MainKt.main(Main.kt:11)
	at asynqueueproblem.MainKt.main(Main.kt)
Complete code can be found here: https://github.com/GeorgePap-719/asyn-request-queue-problem/blob/main/src/main/kotlin/Queue.kt It complains when i am creating an instance of
Node
.
If i change
Node
to something like this:
Copy code
private class Node(
    val job: QueueJob,
    @Suppress("LocalVariableName") _next: Node? = null
) {
    // Pointer to the next node in linked list.
    val next: AtomicRef<Node?> = atomic(_next)

    // Checks if this node is the physical tail of the linked list.
    val isTail: Boolean get() = next.value == null

    fun setNext(newNode: Node) {
        while (true) if (next.compareAndSet(null, newNode)) return
    }
}
The error goes away.