sendMany method

Future<List<R?>> sendMany(
  1. List<IsolateTask<T, R>> tasks
)

Implementation

Future<List<R?>> sendMany(List<IsolateTask<T, R>> tasks) async {
  List<Future<R?>?> futures = List<Future<R>?>.filled(tasks.length, null);
  var i = 0;

  while (i < tasks.length) {
    var task = tasks[i];
    var j = 0;
    while (_workers[j].isTooBusy) {
      j++;
      if (j >= count) {
        await Future<void>.delayed(const Duration(milliseconds: 10));
        j = 0;
      }
    }
    futures[i] = _workers[j].send(task);
    i++;
    j++;
  }

  return Future.wait(futures as Iterable<Future<R?>>);
}