By what mechanism do Kotlin/Native workers request an underlying thread to terminate? I've managed t...
k
By what mechanism do Kotlin/Native workers request an underlying thread to terminate? I've managed to find
requestTerminationInternal
which is an
external fun
so I'm not quite sure how to keep digging on this. I imagine it differs on each platform, but is this documented functionality anywhere? https://github.com/JetBrains/kotlin/blob/30788566012c571aa1d3590912468d1ebe59983d/[…]ve/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt
e
one line up:
Copy code
@GCUnsafeCall("Kotlin_Worker_requestTerminationWorkerInternal")
k
For anyone wondering in the future, it seems that when requesting worker termination, a termination job is placed in the queue of work. The worker will continually take from the queue and when it sees the termination job it breaks the loop and returns. https://github.com/JetBrains/kotlin/blob/dd051c155640ff4b83f1cf1c730bd21387a49453/kotlin-native/runtime/src/main/cpp/Worker.cpp#L998-L1000