5f431e4e87
* Removed deprecated methods from the new atomics in kotlin.concurrent * Changed deprecation level from WARNING to ERROR for the old atomics in kotlin.native.concurrent * Removed FreezingIsDeprecated annotation from kotlin.concurrent.AtomicReference See KT-58123 Merge-request: KT-MR-10650 Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
23 lines
642 B
Kotlin
23 lines
642 B
Kotlin
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class)
|
|
|
|
import kotlinx.cinterop.*
|
|
import kt44283.*
|
|
import kotlin.concurrent.AtomicInt
|
|
import kotlin.test.*
|
|
|
|
val callbackCounter = AtomicInt(0)
|
|
|
|
fun main() {
|
|
val func = staticCFunction<CValue<TestStruct>, Unit> {
|
|
kotlin.native.runtime.GC.collect() // Helps to ensure that "runtime" is already initialized.
|
|
|
|
memScoped {
|
|
println("Hello, Kotlin/Native! ${it.ptr.pointed.d}")
|
|
}
|
|
callbackCounter.incrementAndGet()
|
|
}
|
|
|
|
assertEquals(0, callbackCounter.value)
|
|
invokeFromThread(func.reinterpret())
|
|
assertEquals(1, callbackCounter.value)
|
|
} |