withWorker<R> function
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.
Implementation
external R withWorker<R>({
String? name,
Boolean errorReporting = true,
required R Function() block,
});