W3cubDocs

/Kotlin

withWorker

Platform and version requirements: Native (1.3)
inline fun <R> withWorker(
    name: String? = null, 
    errorReporting: Boolean = true, 
    block: Worker.() -> R
): R

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.

Parameters

name - of the started worker.

errorReporting - controls if uncaught errors in worker to be reported.

block - to be executed.

Return value returned by the block.

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.concurrent/with-worker.html