addTask method

Future addTask(
  1. TaskFutureFuc futureFunc, {
  2. dynamic param,
})

Implementation

Future addTask(TaskFutureFuc futureFunc, {dynamic param}) {
  Completer completer = Completer();
  TaskItem taskItem = TaskItem(
    futureFunc,
    (success, result) {
      if (success) {
        completer.complete(result);
      } else {
        completer.completeError(result);
      }
      _currentRunningCount = _currentRunningCount - 1;
      //递归任务
      _doTask();
    },
  );
  _taskList.add(taskItem);
  _doTask();
  return completer.future;
}