Plan job for further execution in the worker. Execute is a two-phase operation:
- producer function is executed on the caller's thread.
- the result of producer and job function pointer is being added to jobs queue of the selected worker. Note that job must not capture any state itself.
Parameter mode has no effect.
Behavior is more complex in case of legacy memory manager:
- 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.
Note, that some technically disjoint subgraphs may lead to
kotlin.native.runtime.GC.collect()could be called in the end of
jobif garbage cyclic structures or other uncollected objects refer to the value being transferred.
Return the future with the computation result of job.