execute<T1, T2> method

Future<T2> execute<T1, T2>({
  1. required TransferMode mode,
  2. required T1 producer(),
  3. required T2 job(
    1. T1
    ),
})

Plan job for further execution in the worker.

Execute is a two-phase operation:

  1. producer function is executed on the caller's thread.
  2. 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.

Return the future with the computation result of job.

Implementation

external Future<T2> execute<T1, T2>({
  required TransferMode mode,
  required T1 Function() producer,
  required T2 Function(T1) job,
});