executeAndResume

Executes a job the current instance with jobInput as input and then invokes the resumingJob closure on the resumingWorker worker. The resumingJob closure accepts the output of job as the only argument. Both job and resumingJob closures must be non capturing lambdas. The job can be resumed on a different worker by passing resumingWorker argument which is set to the current worker by default. The awaitResumingJob blocks the current instance until resumingJob block is finished. This is useful in testing.

For example

// in main thread
worker.execute("input", {

// executes in worker 1
"$it-processed"
}) {
// executes on main thread
println(it) // prints "$it-processed"
}

Parameters

T

the type of job input

V

the type of job output which resumingJob closure takes as input.

W

the type of resumingJob closure output.

open override fun <T, V, W> executeAndResume(jobInput: T, job: (T) -> V, resumingWorker: Worker, awaitResumingJob: Boolean, resumingJob: (V) -> W): Future<V>