executeTasks method

  1. @override
TResolvableOption<T> executeTasks()
override

Schedules all tasks in the queue for sequential execution.

This operation is non-blocking; it enqueues the tasks in the underlying TaskSequencer and returns immediately.

The final result of all tasks can be retrieved from the returned Resolvable or by accessing the completion property of the sequencer.

Implementation

@override
TResolvableOption<T> executeTasks() {
  _executionCount = tasks.length;
  _executionIndex = 0;
  while (tasks.isNotEmpty) {
    final task = tasks.removeFirst();
    _executeTask(task)
        .then((e) {
          _executionIndex++;
          return _onTaskCompleted?.call(task, executionProgress) ??
              syncUnit();
        })
        .flatten()
        .end();
  }
  return _sequencer.completion;
}