addTask method

void addTask(
  1. Future<void> performSelector(),
  2. int max
)

Implementation

void addTask(Future<void> Function() performSelector, int max) {
    //最多max个任务
    if (_taskList.length >= max) {
        //大于max个后,从头开始删除、保持队列任务是最新的。
        _taskList.removeFirst();
    }
    _TaskInfo taskInfo = _TaskInfo(performSelector);

    /// 添加到任务队列
    _taskList.add(taskInfo);

    /// 触发任务
    _doTask();
}