Worker

Native
1.3
inline class Worker

Class representing worker.

Properties

Native
1.3

id

val id: Int

Functions

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?
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>
Native
1.3

requestTermination

Requests termination of the worker.

fun requestTermination(
    processScheduledJobs: Boolean = true
): Future<Unit>
Native
1.3

toString

Returns a string representation of the object.

fun toString(): String

Companion Object Properties

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

Native
1.3

fromCPointer

Create worker object from a C pointer.

fun fromCPointer(pointer: COpaquePointer?): Worker
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