withWorker

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

(source)

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.