Platform and version requirements: Native (1.3)
fun <T1, T2> execute(
mode: TransferMode,
producer: () -> T1,
job: (T1) -> T2
): Future<T2>
Plan job for further execution in the worker. Execute is a two-phase operation:
- first producer function is executed, and resulting object and whatever it refers to is analyzed for being an isolated object subgraph, if in checked mode.
- Afterwards, this disconnected object graph and job function pointer is being added to jobs queue of the selected worker. Note that job must not capture any state itself, so that whole state is explicitly stored in object produced by producer. Scheduled job is being executed by the worker, and result of such a execution is being disconnected from worker's object graph. Whoever will consume the future, can use result of worker's computations.
Return the future with the computation result of job