W3cubDocs

/Kotlin

Worker

Platform and version requirements: Native (1.3)
inline class Worker

Class representing worker.

Properties

Platform and version requirements: Native (1.3)

id

val id: Int

Functions

Platform and version requirements: Native (1.3)

asCPointer

Convert worker to a COpaquePointer value that could be passed via native void* pointer. Can be used as an argument of Worker.fromCPointer.

fun asCPointer(): COpaquePointer?
Platform and version requirements: Native (1.3)

execute

Plan job for further execution in the worker. Execute is a two-phase operation:

fun <T1, T2> execute(
    mode: TransferMode, 
    producer: () -> T1, 
    job: (T1) -> T2
): Future<T2>
Platform and version requirements: Native (1.3)

requestTermination

Requests termination of the worker.

fun requestTermination(
    processScheduledJobs: Boolean = true
): Future<Unit>
Platform and version requirements: Native (1.3)

toString

Returns a string representation of the object.

fun toString(): String

Companion Object Properties

Platform and version requirements: Native (1.3)

current

Return the current worker, if known, null otherwise. null value will be returned in the main thread or platform thread without an associated worker, non-null - if called inside worker started with Worker.start.

val current: Worker?

Companion Object Functions

Platform and version requirements: Native (1.3)

fromCPointer

Create worker object from a C pointer.

fun fromCPointer(pointer: COpaquePointer?): Worker
Platform and version requirements: Native (1.3)

start

Start new scheduling primitive, such as thread, to accept new tasks via execute interface. Typically new worker may be needed for computations offload to another core, for IO it may be better to use non-blocking IO combined with more lightweight coroutines.

fun start(errorReporting: Boolean = true): Worker

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.concurrent/-worker/index.html