Package kotlin.native.concurrent

Types

Native
1.3

AtomicInt

An Int value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

class AtomicInt
Native
1.3

AtomicLong

A Long value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

class AtomicLong
Native
1.3

AtomicNativePtr

A kotlinx.cinterop.NativePtr value that is always updated atomically. For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

class AtomicNativePtr
Native
1.3

AtomicReference

An object reference that is always updated atomically.

class AtomicReference<T>
Native
1.3

Continuation0

class Continuation0 : () -> Unit
Native
1.3

Continuation1

class Continuation1<T1> : (T1) -> Unit
Native
1.3

Continuation2

class Continuation2<T1, T2> : (T1, T2) -> Unit
Native
1.3

DetachedObjectGraph

Detached object graph encapsulates transferrable detached subgraph which cannot be accessed externally, until it is attached with the attach extension function.

class DetachedObjectGraph<T>
Native
1.3

FreezableAtomicReference

This class was useful only with legacy memory manager. Please use AtomicReference instead.

class FreezableAtomicReference<T>
Native
1.3

FreezingException

Exception thrown whenever freezing is not possible.

class FreezingException : RuntimeException
Native
1.3

Future

class Future<T>
Native
1.3

FutureState

State of the future object.

enum class FutureState
Native
1.3

InvalidMutabilityException

Exception thrown whenever we attempt to mutate frozen objects.

class InvalidMutabilityException : RuntimeException
Native
1.3

MutableData

Mutable concurrently accessible data buffer. Could be accessed from several workers simultaneously.

class MutableData
Native
1.3

TransferMode

Note: modern Kotlin/Native memory manager allows to share objects between threads without additional ceremonies, so TransferMode has effect only in legacy memory manager.

enum class TransferMode
Native
1.3

Worker

class Worker
Native
1.3

WorkerBoundReference

A shared reference to a Kotlin object that doesn't freeze the referred object when it gets frozen itself.

class WorkerBoundReference<out T : Any>

Annotations

Native
1.9

ObsoleteWorkersApi

Marks all Worker-related API as obsolete.

annotation class ObsoleteWorkersApi
Common
Native
1.0

SharedImmutable

Note: this annotation has effect only in Kotlin/Native with legacy memory manager.

annotation class SharedImmutable
Common
Native
1.0

ThreadLocal

Marks a top level property with a backing field or an object as thread local. The object remains mutable and it is possible to change its state, but every thread will have a distinct copy of this object, so changes in one thread are not reflected in another.

annotation class ThreadLocal

Properties

Native
1.3

isFrozen

Checks if given object is null or frozen or permanent (i.e. instantiated at compile-time).

val Any?.isFrozen: Boolean

Functions

Native
1.3

atomicLazy

Atomic lazy initializer, could be used in frozen objects, freezes initializing lambda, so use very carefully. Also, as with other uses of an AtomicReference may potentially leak memory, so it is recommended to use atomicLazy in cases of objects living forever, such as object singletons, or in cases where it's guaranteed not to have cyclical garbage.

fun <T> atomicLazy(initializer: () -> T): Lazy<T>
Native
1.3

attach

Attaches previously detached object subgraph created by DetachedObjectGraph. Please note, that once object graph is attached, the DetachedObjectGraph.stable pointer does not make sense anymore, and shall be discarded, so attach of one DetachedObjectGraph object can only happen once.

fun <T> DetachedObjectGraph<T>.attach(): T
Native
1.3

callContinuation0

fun COpaquePointer.callContinuation0()
Native
1.3

callContinuation1

fun <T1> COpaquePointer.callContinuation1()
Native
1.3

callContinuation2

fun <T1, T2> COpaquePointer.callContinuation2()
Native
1.3

ensureNeverFrozen

This function ensures that if we see such an object during freezing attempt - freeze fails and FreezingException is thrown.

fun Any.ensureNeverFrozen()
Native
1.3

freeze

Freezes object subgraph reachable from this object. Frozen objects can be freely shared between threads/workers.

fun <T> T.freeze(): T
Native
1.3

waitForMultipleFutures

fun <T> Collection<Future<T>>.waitForMultipleFutures(
    millis: Int
): Set<Future<T>>
Native
1.3

waitWorkerTermination

fun waitWorkerTermination(worker: Worker)
Native
1.3

withWorker

Executes block with new Worker as resource, by starting the new worker, calling provided block (in current context) with newly started worker as this and terminating worker after the block completes. Note that this operation is pretty heavyweight, use preconfigured worker or worker pool if need to execute it frequently.

fun <R> withWorker(
    name: String? = null,
    errorReporting: Boolean = true,
    block: Worker.() -> R
): R