execute<R, P> method

void execute<R, P>({
  1. required FutureOr<R> doWork(
    1. P argument
    ),
  2. dynamic call(
    1. R response
    )?,
  3. required P argument,
})

执行多线程微任务 doWork 耗时任务 call 耗时任务执行结果回调 argument 任务执行传入参数

Implementation

void execute<R, P>(
    {required FutureOr<R> Function(P argument) doWork, Function(R response)? call, required P argument}) {
  loadBalancer.then((balancer) {
    balancer.run<R, P>(doWork, argument).then((response) {
      if (call != null) {
        call(response);
      }
    });
  });
}