perform method

void perform({
  1. required String params,
  2. required TaskFunction function,
  3. int maxCount = 1,
})

确保任务执行成功,若执行失败或异常则继续将任务添加至队首等待下次执行; maxCount 最多执行次数

Implementation

void perform({required String params, required TaskFunction function, int maxCount = 1}) {
  _taskQueue.addFirst(KeepFunctionNested(() {
    return Future.value(KeepResponse(params, function, 0, maxCount));
  }));
  if (!_isPerforming) {
    _performTask();
  }
}