utiller 1.0.59 → 1.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,8 @@ exports["default"] = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
12
14
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
15
 
14
16
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -66,6 +68,8 @@ var InfinitePool = /*#__PURE__*/function () {
66
68
  * 一次能處理幾個取決於maxWorker
67
69
  * */
68
70
 
71
+ /** [{state: 'NOT', hash: hash, task: functionOfAsyncTask} ]*/
72
+
69
73
  /** 目前queue機制是while(isQueuePolling) 沒任務就睡一下, 有任務就做事情, 發現task有延遲, 就要注意是不是taskInterval*/
70
74
 
71
75
  /** 為了刪除未執行的task, 但只限於runByTask, 因為下一個run之後, hash就改變了 */
@@ -80,24 +84,23 @@ var InfinitePool = /*#__PURE__*/function () {
80
84
  (0, _defineProperty2["default"])(this, "taskSleepInterval", _configerer.configerer.POOLLER_TASK_OF_INTERVAL_DEFAULT);
81
85
  (0, _defineProperty2["default"])(this, "enableOfTaskTimeout", _configerer.configerer.POOLLER_ENABLE_TIMEOUT);
82
86
  (0, _defineProperty2["default"])(this, "timeOfTaskTimeout", _configerer.configerer.POOLLER_TASK_TIMEOUT_DEFAULT);
83
- (0, _defineProperty2["default"])(this, "taskFailHandler", undefined);
87
+ (0, _defineProperty2["default"])(this, "handlerOfAssignTaskFail", undefined);
84
88
  (0, _defineProperty2["default"])(this, "maxWorker", void 0);
85
89
  (0, _defineProperty2["default"])(this, "ignoreFirstRun", false);
86
- (0, _defineProperty2["default"])(this, "paramQueue", []);
87
- (0, _defineProperty2["default"])(this, "assignedTaskQueue", {});
88
- (0, _defineProperty2["default"])(this, "executingTaskInQueue", []);
90
+ (0, _defineProperty2["default"])(this, "queueOfWaitingParam", []);
91
+ (0, _defineProperty2["default"])(this, "queueOfAssignTask", {});
92
+ (0, _defineProperty2["default"])(this, "queueOfExecutingTask", []);
89
93
  (0, _defineProperty2["default"])(this, "isQueuePolling", false);
90
- (0, _defineProperty2["default"])(this, "dispatchers", []);
91
- (0, _defineProperty2["default"])(this, "initialTaskKickOff", false);
92
- (0, _defineProperty2["default"])(this, "mHashNTaskMap", {});
93
- (0, _defineProperty2["default"])(this, "hashCallbackMapOfWaiting4Result", {});
94
- (0, _defineProperty2["default"])(this, "poolId", "");
94
+ (0, _defineProperty2["default"])(this, "initialTaskCompleted", false);
95
+ (0, _defineProperty2["default"])(this, "mapOfHashNTask", {});
96
+ (0, _defineProperty2["default"])(this, "mapOfHashNCallbackWrapper", {});
97
+ (0, _defineProperty2["default"])(this, "nameOfCurrentPool", "");
95
98
  (0, _defineProperty2["default"])(this, "setPoolId", function () {
96
- var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.poolId;
97
- _this.poolId = id;
99
+ var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.nameOfCurrentPool;
100
+ _this.nameOfCurrentPool = id;
98
101
  });
99
102
  (0, _defineProperty2["default"])(this, "getPoolId", function () {
100
- return _this.poolId;
103
+ return _this.nameOfCurrentPool;
101
104
  });
102
105
  (0, _defineProperty2["default"])(this, "stopInBackground", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
103
106
  return _regenerator["default"].wrap(function _callee$(_context) {
@@ -107,16 +110,16 @@ var InfinitePool = /*#__PURE__*/function () {
107
110
  _this.terminate();
108
111
 
109
112
  case 1:
110
- if (!(_lodash["default"].size(_this.executingTaskInQueue) > 0)) {
113
+ if (!(_lodash["default"].size(_this.queueOfExecutingTask) > 0)) {
111
114
  _context.next = 8;
112
115
  break;
113
116
  }
114
117
 
115
118
  _context.next = 4;
116
- return _index2.utiller.syncDelay(1000);
119
+ return _index2.utiller.syncDelay(500);
117
120
 
118
121
  case 4:
119
- _index2.utiller.appendInfo(_this.getPoollerLogFormat("\u54AC\u5728 stopInBackground \u51FA\u4E0D\u4F86"));
122
+ _this.printLogMessage("784512, \u54AC\u5728 stopInBackground \u51FA\u4E0D\u4F86,".concat(_this.getLogMessageOfExecutingTaskQueueCount()));
120
123
 
121
124
  _this.showState();
122
125
 
@@ -138,7 +141,7 @@ var InfinitePool = /*#__PURE__*/function () {
138
141
  });
139
142
  (0, _defineProperty2["default"])(this, "getTaskQueueCount", function () {
140
143
  var size = 0;
141
- if (_this.state === _configerer.configerer.POOLLER_STATE.RUN_BY_PARAMS) return _this.paramQueue.length;
144
+ if (_this.state === _configerer.configerer.POOLLER_STATE.RUN_BY_PARAMS) return _this.queueOfWaitingParam.length;
142
145
 
143
146
  var _iterator = _createForOfIteratorHelper(_configerer.configerer.POOLLER_PRIORITY),
144
147
  _step;
@@ -146,7 +149,7 @@ var InfinitePool = /*#__PURE__*/function () {
146
149
  try {
147
150
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
148
151
  var prior = _step.value;
149
- size += _this.assignedTaskQueue[prior].length;
152
+ size += _this.queueOfAssignTask[prior].length;
150
153
  }
151
154
  } catch (err) {
152
155
  _iterator.e(err);
@@ -173,27 +176,42 @@ var InfinitePool = /*#__PURE__*/function () {
173
176
 
174
177
  _this.appendHashTaskMap(taskInfo);
175
178
 
176
- _this.assignedTaskQueue[priority].push(taskInfo);
179
+ _this.queueOfAssignTask[priority].push(taskInfo);
177
180
 
178
181
  return hash;
179
182
  } else {
180
183
  throw new _exceptioner["default"](4002, "task can't be ".concat((0, _typeof2["default"])(task)));
181
184
  }
182
185
  });
186
+ (0, _defineProperty2["default"])(this, "updateExecuteTaskState", function (hash) {
187
+ var self = _this;
188
+
189
+ var task = _lodash["default"].find(_this.queueOfExecutingTask, function (each) {
190
+ return _lodash["default"].isEqual(each.hash, hash);
191
+ });
192
+
193
+ if (task) {
194
+ _this.printLogMessage("847875153, \u5BA2\u7AEF\u59D4\u8A17\u7684\u4EFB\u52D9: ".concat(hash, ",\u66F4\u6539\u72C0\u614B\u70BA 'ING'"));
195
+
196
+ task.state = "ING";
197
+ }
198
+ });
183
199
  (0, _defineProperty2["default"])(this, "taskWrapper", function (assignedTask, hashOfTask) {
184
200
  return function () {
185
201
  var self = _this;
186
202
  var timeoutHash = "";
187
203
  var assignedTaskResult;
188
204
  var assignedTaskError;
189
- var param = self.paramQueue.shift();
190
- var isAssignedTaskCompeleted = true;
205
+ var param = self.queueOfWaitingParam.shift();
206
+ var isAssignedTaskCompleted = true;
191
207
  /** 用來判斷task 有沒有走到 catch裡面, 不然resolve了但return undefined, task會不知所措 */
192
208
 
193
209
  return new Promise(function (resolve, reject) {
194
210
  if (self.enableOfTaskTimeout) {
195
211
  timeoutHash = setTimeout(function () {
196
212
  try {
213
+ _this.printLogMessage("982532, taskWrapper\u57F7\u884C\u4E2D,\u767C\u751Ftimout: ".concat(self.timeOfTaskTimeout, " ms"));
214
+
197
215
  throw new _exceptioner["default"](4010, self.getPoollerLogFormat("TASK HASH:".concat(hashOfTask, " IS TIMEOUT ").concat(self.timeOfTaskTimeout, " ms ").concat(param ? ",PARAMS IS ".concat(JSON.stringify(param)) : "")));
198
216
  } catch (error) {
199
217
  reject(error);
@@ -201,52 +219,54 @@ var InfinitePool = /*#__PURE__*/function () {
201
219
  }, self.timeOfTaskTimeout);
202
220
  }
203
221
  /** 客端委託的task的是從這裡開始 */
204
- // Util.appendInfo(self.getPoollerLogFormat(`客端委託的task開始執行 ${hashOfTask}`));
205
222
 
206
223
 
224
+ _this.printLogMessage("984135, \u5BA2\u7AEF\u59D4\u8A17\u7684task\u958B\u59CB\u57F7\u884C ".concat(hashOfTask));
225
+
226
+ self.updateExecuteTaskState(hashOfTask);
207
227
  assignedTask(param).then(function (result) {
208
- // console.log(self.getPoollerLogFormat('task get result'));
228
+ _this.printLogMessage("984545, \u5BA2\u7AEF\u59D4\u8A17\u7684\u4EFB\u52D9,resolve\u56DE\u61C9: ".concat(result));
229
+
209
230
  assignedTaskResult = result;
210
- isAssignedTaskCompeleted = true;
231
+ isAssignedTaskCompleted = true;
211
232
  })["catch"](function (error) {
212
- // console.error(self.getPoollerLogFormat('委託任務發生錯誤'), error);
233
+ _this.printLogMessage("989652, \u5BA2\u7AEF\u59D4\u8A17\u7684\u4EFB\u52D9,reject\u56DE\u61C9: ".concat(error.message), true, error);
234
+
213
235
  assignedTaskError = error;
214
- isAssignedTaskCompeleted = false;
236
+ isAssignedTaskCompleted = false;
215
237
  })["finally"](function () {
216
238
  clearTimeout(timeoutHash);
217
- /** 要記得 resolve, reject 在這裡代表的是放在executingQueue裡面的promise, reject,resolve其中一個必須觸發, executingQueue才不會堵塞
218
- ** 而任務需要的task是透過 removeResolveOrRejectPromiseByHash() */
219
- // console.info(self.getPoollerLogFormat(self.getPoollerLogFormat('inner finally')));
239
+ resolve();
220
240
 
221
- resolve("".concat(hashOfTask, " done"));
241
+ _this.printLogMessage("98942, taskWrapper()\u88E1\u9762\u7B2C\u4E00\u500Bpromise(\u70BA\u4E86timeout\u8A2D\u8A08)\u5B8C\u6210\u4E86");
222
242
  });
223
243
  }).then(function (result) {
224
- /** 再沒有timeout的狀況下,執行了委託的任務(委託任務可能成功也可能進到catch) */
225
- if (!isAssignedTaskCompeleted) {
244
+ /** 能走到這裡,代表沒有timeout的狀況下,執行了委託的任務 */
245
+ if (!isAssignedTaskCompleted) {
226
246
  throw assignedTaskError;
247
+ } else {
248
+ return "".concat(_this.getLogMessageOfTaskHash(hashOfTask), " completed");
227
249
  }
228
250
  })["catch"](function (error) {
229
- // console.error(self.getPoollerLogFormat(self.getPoollerLogFormat('outer error')), error);
230
-
231
- /** 如果發生timeout 或是 assign task 掉進去catch 都會跑到這裡 */
232
- isAssignedTaskCompeleted = false;
251
+ /** 如果發生timeout 或是 客端任務掉進去catch都會跑到這裡 */
252
+ isAssignedTaskCompleted = false;
233
253
  assignedTaskError = error;
234
254
  /** 如果是Wait4ResultTask模式, 要把catch | result 回到callbackWrapper */
235
255
 
236
256
  if (!self.isWait4ResultTask(hashOfTask)) {
237
- if (self.taskFailHandler !== undefined) {
238
- self.taskFailHandler(assignedTaskError);
257
+ if (self.handlerOfAssignTaskFail !== undefined) {
258
+ self.handlerOfAssignTaskFail(assignedTaskError);
239
259
  } else throw assignedTaskError;
240
260
  }
241
261
  })["finally"](function () {
242
- // console.info(self.getPoollerLogFormat(self.getPoollerLogFormat('outer finally')));
243
262
  var result = {
244
- taskResolved: isAssignedTaskCompeleted,
263
+ assignedTaskCompleted: isAssignedTaskCompleted,
245
264
  resolve: assignedTaskResult,
246
265
  reject: assignedTaskError
247
- }; // Util.appendInfo('客端委託的task執行完回傳的內容', result, hashOfTask)
248
-
266
+ };
249
267
  self.removeResolveOrRejectPromiseByHash(hashOfTask, result);
268
+
269
+ _this.printLogMessage("98943213, ".concat(_this.getTaskInfoByHash(hashOfTask), " taskWrapper()\u88E1\u9762\u7B2C2\u500Bpromise\u5B8C\u6210\u4E86"), result);
250
270
  });
251
271
  };
252
272
  });
@@ -275,7 +295,7 @@ var InfinitePool = /*#__PURE__*/function () {
275
295
  return hashes;
276
296
  });
277
297
  (0, _defineProperty2["default"])(this, "removeTaskMapByHash", function (hash) {
278
- delete _this.mHashNTaskMap[hash];
298
+ delete _this.mapOfHashNTask[hash];
279
299
  });
280
300
  (0, _defineProperty2["default"])(this, "beforeRun", function () {
281
301
  _this.isQueuePolling = true;
@@ -329,25 +349,33 @@ var InfinitePool = /*#__PURE__*/function () {
329
349
  _this.setState(_configerer.configerer.POOLLER_STATE.RUN_INFINITE);
330
350
 
331
351
  case 14:
332
- if (!_this.isRunning()) {
333
- _context2.next = 19;
352
+ if (!_this.ruleOfInfiniteRun()) {
353
+ _context2.next = 20;
334
354
  break;
335
355
  }
336
356
 
337
- _context2.next = 17;
357
+ _this.printLogMessage("415123, runInInfinite() \u6B63\u5728\u7121\u9650Loop\u4E2D,".concat(_this.getLogMessageOfExecutingTaskQueueCount()));
358
+
359
+ _context2.next = 18;
338
360
  return (0, _classPrivateFieldGet2["default"])(_this, _run).call(_this);
339
361
 
340
- case 17:
362
+ case 18:
341
363
  _context2.next = 14;
342
364
  break;
343
365
 
344
- case 19:
366
+ case 20:
345
367
  case "end":
346
368
  return _context2.stop();
347
369
  }
348
370
  }
349
371
  }, _callee2);
350
372
  })));
373
+ (0, _defineProperty2["default"])(this, "ruleOfInfiniteRun", function () {
374
+ return _this.isRunning() || !_this.isExecutingTaskQueueEmpty();
375
+ });
376
+ (0, _defineProperty2["default"])(this, "isExecutingTaskQueueEmpty", function () {
377
+ return _lodash["default"].size(_this.queueOfExecutingTask) === 0;
378
+ });
351
379
  (0, _defineProperty2["default"])(this, "appendParamInToQueue", function () {
352
380
  for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
353
381
  params[_key] = arguments[_key];
@@ -356,7 +384,7 @@ var InfinitePool = /*#__PURE__*/function () {
356
384
  for (var _i = 0, _params = params; _i < _params.length; _i++) {
357
385
  var param = _params[_i];
358
386
 
359
- _this.paramQueue.push(param);
387
+ _this.queueOfWaitingParam.push(param);
360
388
  }
361
389
  });
362
390
  (0, _defineProperty2["default"])(this, "runByParams", /*#__PURE__*/function () {
@@ -399,7 +427,7 @@ var InfinitePool = /*#__PURE__*/function () {
399
427
  _this.beforeRun();
400
428
 
401
429
  case 9:
402
- if (!(_this.isRunning() && !_lodash["default"].isEmpty(_this.paramQueue))) {
430
+ if (!(_this.ruleOfInfiniteRun() && !_lodash["default"].isEmpty(_this.queueOfWaitingParam))) {
403
431
  _context3.next = 14;
404
432
  break;
405
433
  }
@@ -449,26 +477,25 @@ var InfinitePool = /*#__PURE__*/function () {
449
477
  _this.setState(_configerer.configerer.POOLLER_STATE.RUN_BY_EACH_TASK);
450
478
 
451
479
  case 5:
452
- if (!_this.isRunning()) {
480
+ if (!_this.ruleOfInfiniteRun()) {
453
481
  _context4.next = 11;
454
482
  break;
455
483
  }
456
484
 
485
+ _context4.next = 8;
486
+ return (0, _classPrivateFieldGet2["default"])(_this, _run).call(_this, _this.id);
487
+
488
+ case 8:
457
489
  if (_this.getTaskQueueCount() <= 0) {
458
490
  _this.terminate();
459
- }
460
491
 
461
- _context4.next = 9;
462
- return (0, _classPrivateFieldGet2["default"])(_this, _run).call(_this, _this.id);
492
+ _this.printLogMessage("788121, runByEachTask() \u56E0\u70BA taskOfWaitingQueue \u6E05\u7A7A\u800C\u505C\u6B62");
493
+ }
463
494
 
464
- case 9:
465
495
  _context4.next = 5;
466
496
  break;
467
497
 
468
498
  case 11:
469
- _this.terminate();
470
-
471
- case 12:
472
499
  case "end":
473
500
  return _context4.stop();
474
501
  }
@@ -552,7 +579,7 @@ var InfinitePool = /*#__PURE__*/function () {
552
579
 
553
580
  _this.terminate();
554
581
 
555
- _index2.utiller.appendInfo("".concat(_this.getPoollerLogFormat("background instance terminated"), " "));
582
+ _this.printLogMessage("7812123, runInBackGround() \u8D70\u5230finally");
556
583
 
557
584
  return _context6.finish(8);
558
585
 
@@ -565,78 +592,78 @@ var InfinitePool = /*#__PURE__*/function () {
565
592
  })), 1);
566
593
  });
567
594
  (0, _defineProperty2["default"])(this, "getPoollerLogFormat", function (msg) {
568
- return "POOLLER ID: ".concat(_this.getPoolId()).concat(_lodash["default"].isEmpty(msg) ? "" : " , ").concat(msg);
595
+ return "POOLLER NAME: ".concat(_this.getPoolId()).concat(_lodash["default"].isEmpty(msg) ? "" : " , ").concat(msg);
569
596
  });
570
597
  (0, _defineProperty2["default"])(this, "setTaskFailHandler", function () {
571
598
  var listener = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (error) {
572
599
  return console.log(error.message);
573
600
  };
574
- _this.taskFailHandler = listener;
575
- });
576
- (0, _defineProperty2["default"])(this, "touchTaskDispatcher", function () {
577
- var dispatcher = setTimeout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
578
- return _regenerator["default"].wrap(function _callee7$(_context7) {
579
- while (1) {
580
- switch (_context7.prev = _context7.next) {
581
- case 0:
582
- _context7.next = 2;
583
- return _this.syncTaskDispatcher();
584
-
585
- case 2:
586
- _this.dispatchers.splice(_this.dispatchers.indexOf(dispatcher), 1);
587
-
588
- case 3:
589
- case "end":
590
- return _context7.stop();
591
- }
592
- }
593
- }, _callee7);
594
- })), 0);
595
-
596
- _this.dispatchers.push(dispatcher);
601
+ _this.handlerOfAssignTaskFail = listener;
597
602
  });
598
- (0, _defineProperty2["default"])(this, "appendToExecuteQueue", function (hash, promise) {
599
- _this.executingTaskInQueue.push({
603
+ (0, _defineProperty2["default"])(this, "appendTaskToExecuteQueue", function (hash, promise) {
604
+ var task = {
605
+ state: "NOT",
600
606
  hash: hash,
601
607
  task: promise
602
- }); // Util.appendInfo(`\n\n新增了一個任務${hash} 進入executingTaskQueue ==>`, this.executingTaskInQueue)
608
+ };
609
+
610
+ _this.printLogMessage("4484451, \u589E\u52A0\u4E86\u4E00\u500BassignedTask ".concat(_this.getLogMessageOfTaskHash(hash), " \u5230 QueueOfExecutingTask ,").concat(_this.getLogMessageOfExecutingTaskQueueCount), false, task);
603
611
 
612
+ _this.queueOfExecutingTask.push(task);
613
+ });
614
+ (0, _defineProperty2["default"])(this, "getLogMessageOfExecutingTaskQueueCount", function () {
615
+ return "ExecutingTaskQueueCount: ".concat(_lodash["default"].size(_this.queueOfExecutingTask));
616
+ });
617
+ (0, _defineProperty2["default"])(this, "getLogMessageOfTaskHash", function (hash) {
618
+ return "TASK HASH: ".concat(hash);
604
619
  });
605
620
  (0, _defineProperty2["default"])(this, "showState", function () {
606
621
  _index2.utiller.appendInfo(_this.getPoollerLogFormat("workerCount: ".concat(_this.maxWorker)));
607
622
 
608
623
  _index2.utiller.appendInfo(_this.getPoollerLogFormat("taskQueue(\u9084\u5728\u6392\u968A\u7684Task): ".concat(_this.getTaskQueueCount())));
609
624
 
610
- _index2.utiller.appendInfo(_this.getPoollerLogFormat("executingQueue(\u6B63\u5728\u57F7\u884C\u7684AsyncTask, \u8D85\u904EworkerCount\u5C31\u662Fbug): ".concat(_this.executingTaskInQueue.length)));
625
+ _index2.utiller.appendInfo(_this.getPoollerLogFormat("QueueOfExecutingTask(\u6B63\u5728\u57F7\u884C\u7684AsyncTask, \u8D85\u904EworkerCount\u5C31\u662Fbug): ".concat(_lodash["default"].size(_this.queueOfExecutingTask))));
611
626
 
612
- _index2.utiller.appendInfo(_this.getPoollerLogFormat("mHashNTaskMap(\u9084\u6C92\u57F7\u884C\u5230\u7684AsyncTask reference\u7684\u66AB\u5B58\u5340): ".concat(_lodash["default"].size(_this.mHashNTaskMap))));
627
+ _index2.utiller.appendInfo(_this.getPoollerLogFormat("mapOfHashNTask(\u9084\u6C92\u57F7\u884C\u5230\u7684AsyncTask reference\u7684\u66AB\u5B58\u5340): ".concat(_lodash["default"].size(_this.mapOfHashNTask))));
613
628
  });
614
629
 
615
630
  _run.set(this, {
616
631
  writable: true,
617
632
  value: function () {
618
- var _value = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
619
- var self, get, execute, _execute;
633
+ var _value = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
634
+ var self, execute, _execute, task;
620
635
 
621
- return _regenerator["default"].wrap(function _callee9$(_context9) {
636
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
622
637
  while (1) {
623
- switch (_context9.prev = _context9.next) {
638
+ switch (_context8.prev = _context8.next) {
624
639
  case 0:
625
640
  _execute = function _execute3() {
626
- _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
627
- return _regenerator["default"].wrap(function _callee8$(_context8) {
641
+ _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
642
+ var tasks;
643
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
628
644
  while (1) {
629
- switch (_context8.prev = _context8.next) {
645
+ switch (_context7.prev = _context7.next) {
630
646
  case 0:
631
- _context8.next = 2;
632
- return Promise.race(get());
647
+ tasks = self.queueOfExecutingTask.filter(function (each) {
648
+ return _lodash["default"].isEqual(each.state, "NOT");
649
+ }).map(function (each) {
650
+ var task = each.task;
651
+ return task();
652
+ });
653
+ /** Util.appendInfo(`\n\n正要執行的隊列`,self.queueOfExecutingTask) */
654
+
655
+ _context7.next = 3;
656
+ return Promise.race(tasks);
657
+
658
+ case 3:
659
+ return _context7.abrupt("return", _context7.sent);
633
660
 
634
- case 2:
661
+ case 4:
635
662
  case "end":
636
- return _context8.stop();
663
+ return _context7.stop();
637
664
  }
638
665
  }
639
- }, _callee8);
666
+ }, _callee7);
640
667
  }));
641
668
  return _execute.apply(this, arguments);
642
669
  };
@@ -645,54 +672,42 @@ var InfinitePool = /*#__PURE__*/function () {
645
672
  return _execute.apply(this, arguments);
646
673
  };
647
674
 
648
- get = function _get() {
649
- return self.executingTaskInQueue.map(function (each) {
650
- var task = each.task;
651
- return task();
652
- });
653
- };
654
-
655
675
  self = _this;
656
- _context9.next = 6;
676
+ _context8.next = 5;
657
677
  return _this.syncTaskDispatcher();
658
678
 
659
- case 6:
660
- if (!(_this.executingTaskInQueue.length >= _this.maxWorker)) {
661
- _context9.next = 11;
679
+ case 5:
680
+ if (_this.isExecutingTaskQueueEmpty()) {
681
+ _context8.next = 13;
662
682
  break;
663
683
  }
664
684
 
665
- _context9.next = 9;
685
+ /** 當pool已經被要求停止時, executeQueue裡面還有未做完的任務*/
686
+ _this.printLogMessage("4512211, \u958B\u59CB\u4EFB\u52D9(taskWrapper): ".concat(_this.getLogMessageOfExecutingTaskQueueCount()));
687
+
688
+ _context8.next = 9;
666
689
  return execute();
667
690
 
668
691
  case 9:
669
- _context9.next = 14;
670
- break;
692
+ task = _context8.sent;
671
693
 
672
- case 11:
673
- if (!(_this.getTaskQueueCount() === 0 && _this.executingTaskInQueue.length > 0)) {
674
- _context9.next = 14;
675
- break;
676
- }
694
+ _this.printLogMessage("4512213 \u5B8C\u7562\u4EFB\u52D9(taskWrapper:".concat(task, "), ").concat(_this.getLogMessageOfExecutingTaskQueueCount()));
677
695
 
678
- _context9.next = 14;
679
- return execute();
696
+ _context8.next = 14;
697
+ break;
680
698
 
681
- case 14:
682
- if (_this.executingTaskInQueue.length > _this.maxWorker) {
683
- _index2.utiller.appendError("\u4E00\u5B9A\u662F\u6539\u58DE\u4E86\uFF01\uFF01\uFF01\uFF01 ".concat(_this.getPoollerLogFormat("executing queue ".concat(_this.executingTaskInQueue.length, " !!"))));
684
- }
685
- /** 只要完成run 就要把sleepTimeCount歸零
686
- * this.currentSleepCounts = 0;
687
- */
699
+ case 13:
700
+ _index2.utiller.appendInfo(_this.getPoollerLogFormat("4574152 \u4E0D\u61C9\u8A72\u8D70\u5230\u9019\u88CF,\u4F46\u662F minor issue"));
688
701
 
702
+ case 14:
703
+ if (_this.queueOfExecutingTask.length > _this.maxWorker) _this.printLogMessage("4512214 \u4E00\u5B9A\u662F\u6539\u58DE\u4E86!!!!!!!!!!, ".concat(_this.getLogMessageOfExecutingTaskQueueCount, " "), true);
689
704
 
690
705
  case 15:
691
706
  case "end":
692
- return _context9.stop();
707
+ return _context8.stop();
693
708
  }
694
709
  }
695
- }, _callee9);
710
+ }, _callee8);
696
711
  }));
697
712
 
698
713
  function value() {
@@ -711,15 +726,15 @@ var InfinitePool = /*#__PURE__*/function () {
711
726
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
712
727
  var prior = _step3.value;
713
728
 
714
- if (_this.assignedTaskQueue[prior].length > 0) {
729
+ if (_this.queueOfAssignTask[prior].length > 0) {
715
730
  switch (_this.state) {
716
731
  case _configerer.configerer.POOLLER_STATE.RUN_BY_EACH_TASK:
717
- return _this.assignedTaskQueue[prior].shift();
732
+ return _this.queueOfAssignTask[prior].shift();
718
733
 
719
734
  case _configerer.configerer.POOLLER_STATE.RUN_BY_PARAMS:
720
735
  case _configerer.configerer.POOLLER_STATE.RUN_BY_TIMES:
721
736
  case _configerer.configerer.POOLLER_STATE.RUN_INFINITE:
722
- var taskInfo = _this.assignedTaskQueue[prior].shift();
737
+ var taskInfo = _this.queueOfAssignTask[prior].shift();
723
738
 
724
739
  _this.add(taskInfo.task);
725
740
 
@@ -739,18 +754,19 @@ var InfinitePool = /*#__PURE__*/function () {
739
754
  if (!_lodash["default"].isEqual(_this.state, _configerer.configerer.POOLLER_STATE.RUN_BY_EACH_TASK)) throw new _exceptioner["default"](4007);
740
755
  });
741
756
  (0, _defineProperty2["default"])(this, "removeResolveOrRejectPromiseByHash", function (hash, result) {
742
- var callbackWrapper = _this.hashCallbackMapOfWaiting4Result[hash];
757
+ var callbackWrapper = _this.mapOfHashNCallbackWrapper[hash];
743
758
 
744
759
  if (callbackWrapper !== undefined) {
745
760
  callbackWrapper(result);
746
- delete _this.hashCallbackMapOfWaiting4Result[hash];
761
+ delete _this.mapOfHashNCallbackWrapper[hash];
747
762
  }
748
763
 
749
764
  _this.removePromiseFromExecutingQueue(hash);
750
765
  });
751
766
  (0, _defineProperty2["default"])(this, "removePromiseFromExecutingQueue", function (hash) {
752
- // console.log(`executingTaskQueue 拿掉了完成的任務 ${hash}`)
753
- _lodash["default"].remove(_this.executingTaskInQueue, function (each) {
767
+ _this.printLogMessage("QueueOfExecutingTask \u62FF\u6389\u4E86\u5B8C\u6210\u7684\u4EFB\u52D9 ".concat(_this.getLogMessageOfTaskHash(hash)));
768
+
769
+ _lodash["default"].remove(_this.queueOfExecutingTask, function (each) {
754
770
  return _lodash["default"].isEqual(hash, each.hash);
755
771
  });
756
772
  });
@@ -780,7 +796,7 @@ var InfinitePool = /*#__PURE__*/function () {
780
796
  try {
781
797
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
782
798
  var prior = _step4.value;
783
- this.assignedTaskQueue[prior] = [];
799
+ this.queueOfAssignTask[prior] = [];
784
800
  }
785
801
  } catch (err) {
786
802
  _iterator4.e(err);
@@ -806,16 +822,28 @@ var InfinitePool = /*#__PURE__*/function () {
806
822
  }, {
807
823
  key: "clearCache",
808
824
  value: function clearCache() {
809
- this.executingTaskInQueue.length = 0;
810
- this.mHashNTaskMap = {};
811
- this.assignedTaskQueue = {};
825
+ this.queueOfExecutingTask.length = 0;
826
+ this.mapOfHashNTask = {};
827
+ this.queueOfAssignTask = {};
812
828
  }
813
829
  }, {
814
830
  key: "terminate",
815
831
  value: function terminate() {
816
832
  this.isQueuePolling = false;
817
833
  }
818
- /** return true if task completed, after 15 secs, force leave */
834
+ }, {
835
+ key: "printLogMessage",
836
+ value: function printLogMessage(message) {
837
+ var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
838
+
839
+ for (var _len5 = arguments.length, infos = new Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
840
+ infos[_key5 - 2] = arguments[_key5];
841
+ }
842
+
843
+ _index2.utiller.printLogMessage.apply(_index2.utiller, [this.getPoollerLogFormat(message), error].concat(infos));
844
+ }
845
+ /** return true if task completed, after 15 secs, force leave
846
+ * TODO:應該要設計成當terminate後, 監聽executingTaskInQueue為零時,回傳結束 */
819
847
 
820
848
  }, {
821
849
  key: "setWorker",
@@ -861,22 +889,22 @@ var InfinitePool = /*#__PURE__*/function () {
861
889
  }, {
862
890
  key: "addTaskAndWait4Result",
863
891
  value: function () {
864
- var _addTaskAndWait4Result = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(asyncTask) {
892
+ var _addTaskAndWait4Result = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(asyncTask) {
865
893
  var _this2 = this;
866
894
 
867
895
  var priority,
868
896
  taskName,
869
- _args10 = arguments;
870
- return _regenerator["default"].wrap(function _callee10$(_context10) {
897
+ _args9 = arguments;
898
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
871
899
  while (1) {
872
- switch (_context10.prev = _context10.next) {
900
+ switch (_context9.prev = _context9.next) {
873
901
  case 0:
874
- priority = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : "low";
875
- taskName = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : "noName";
902
+ priority = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : "low";
903
+ taskName = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : "noName";
876
904
  this.trigger();
877
- return _context10.abrupt("return", new Promise(function (resolve, reject) {
905
+ return _context9.abrupt("return", new Promise(function (resolve, reject) {
878
906
  var callbackWrapper = function callbackWrapper(result) {
879
- if (result.taskResolved) {
907
+ if (result.assignedTaskCompleted) {
880
908
  resolve(result.resolve);
881
909
  } else {
882
910
  reject(result.reject);
@@ -890,10 +918,10 @@ var InfinitePool = /*#__PURE__*/function () {
890
918
 
891
919
  case 4:
892
920
  case "end":
893
- return _context10.stop();
921
+ return _context9.stop();
894
922
  }
895
923
  }
896
- }, _callee10, this);
924
+ }, _callee9, this);
897
925
  }));
898
926
 
899
927
  function addTaskAndWait4Result(_x4) {
@@ -905,25 +933,22 @@ var InfinitePool = /*#__PURE__*/function () {
905
933
  }, {
906
934
  key: "registerHash4Result",
907
935
  value: function registerHash4Result(hash, callback) {
908
- this.hashCallbackMapOfWaiting4Result[hash] = callback;
936
+ this.mapOfHashNCallbackWrapper[hash] = callback;
909
937
  }
910
938
  }, {
911
939
  key: "appendHashTaskMap",
912
940
  value: function appendHashTaskMap(taskInfo) {
913
- this.mHashNTaskMap[taskInfo.hash] = taskInfo;
941
+ this.mapOfHashNTask[taskInfo.hash] = taskInfo;
914
942
  }
915
943
  }, {
916
944
  key: "getTaskInfoByHash",
917
945
  value: function getTaskInfoByHash(hash) {
918
- return this.mHashNTaskMap[hash];
946
+ return this.mapOfHashNTask[hash];
919
947
  }
920
948
  /**
921
949
  * remove task in queue by its hash, hash was created when add to queue
922
- *
923
950
  * method will return true when succeed delete
924
- *
925
951
  * 放到executing queue, 就沒辦法刪除了
926
- *
927
952
  **/
928
953
 
929
954
  }, {
@@ -939,10 +964,10 @@ var InfinitePool = /*#__PURE__*/function () {
939
964
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
940
965
  var prior = _step5.value;
941
966
 
942
- var _index = _lodash["default"].indexOf(this.assignedTaskQueue[prior], taskInfo);
967
+ var _index = _lodash["default"].indexOf(this.queueOfAssignTask[prior], taskInfo);
943
968
 
944
969
  if (_index > 0) {
945
- this.assignedTaskQueue[prior].splice(_index, 1);
970
+ this.queueOfAssignTask[prior].splice(_index, 1);
946
971
  this.removeTaskMapByHash(hash);
947
972
  return true;
948
973
  }
@@ -967,14 +992,14 @@ var InfinitePool = /*#__PURE__*/function () {
967
992
  this.state = _state;
968
993
  }
969
994
  }, {
970
- key: "firstTaskDone",
971
- value: function firstTaskDone() {
972
- if (!this.initialTaskKickOff) {
973
- this.initialTaskKickOff = true;
995
+ key: "isFirstTaskCompleted",
996
+ value: function isFirstTaskCompleted() {
997
+ if (!this.initialTaskCompleted) {
998
+ this.initialTaskCompleted = true;
974
999
  return false;
975
1000
  }
976
1001
 
977
- return this.initialTaskKickOff;
1002
+ return this.initialTaskCompleted;
978
1003
  }
979
1004
  /** 如果設定interval, 第一個run不要執行的話,就設定true, default是false */
980
1005
 
@@ -1002,59 +1027,73 @@ var InfinitePool = /*#__PURE__*/function () {
1002
1027
  throw new _exceptioner["default"](4011, "this.state is ==> ".concat(_index2.utiller.getItsKeyByValue(_configerer.configerer.POOLLER_STATE, this.state)));
1003
1028
  }
1004
1029
  }, {
1005
- key: "isQueueFull",
1006
- value: function isQueueFull() {
1007
- return this.executingTaskInQueue.length >= this.maxWorker - 1;
1030
+ key: "isExecutingQueueFull",
1031
+ value: function isExecutingQueueFull() {
1032
+ return _lodash["default"].size(this.queueOfExecutingTask) >= this.maxWorker;
1033
+ }
1034
+ }, {
1035
+ key: "isTaskQueueEmpty",
1036
+ value: function isTaskQueueEmpty() {
1037
+ return this.getTaskQueueCount() === 0;
1008
1038
  }
1009
1039
  /** 依照config 把委託任務放置到Queue裡面 */
1010
1040
 
1011
1041
  }, {
1012
1042
  key: "syncTaskDispatcher",
1013
1043
  value: function () {
1014
- var _syncTaskDispatcher = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
1044
+ var _syncTaskDispatcher = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
1015
1045
  var initialTaskShouldNotRun, restInInterval, taskInfo, promise;
1016
- return _regenerator["default"].wrap(function _callee11$(_context11) {
1046
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
1017
1047
  while (1) {
1018
- switch (_context11.prev = _context11.next) {
1048
+ switch (_context10.prev = _context10.next) {
1019
1049
  case 0:
1020
- initialTaskShouldNotRun = this.ignoreFirstRun && !this.firstTaskDone();
1050
+ initialTaskShouldNotRun = this.ignoreFirstRun && !this.isFirstTaskCompleted();
1021
1051
 
1022
- if (!(initialTaskShouldNotRun || this.firstTaskDone() && this.isQueueFull() && this.enableOfTaskSleepByInterval)) {
1023
- _context11.next = 9;
1052
+ if (!(initialTaskShouldNotRun || this.isFirstTaskCompleted() && this.isExecutingQueueFull() && this.enableOfTaskSleepByInterval)) {
1053
+ _context10.next = 6;
1024
1054
  break;
1025
1055
  }
1026
1056
 
1027
- _context11.next = 4;
1057
+ _context10.next = 4;
1028
1058
  return _index2.utiller.syncDelayRandom(this.taskSleepInterval.min, this.taskSleepInterval.max);
1029
1059
 
1030
1060
  case 4:
1031
- restInInterval = _context11.sent;
1032
- if (_configerer.configerer.MODULE_MSG.SHOW_SUCCEED) _index2.utiller.appendInfo("".concat(this.getPoollerLogFormat("Dispatcher \u7167\u898F\u77E9 \u7761 ".concat(restInInterval, " million-secs \u5F8C\u624D\u80FDDispatch AsyncTask")), " "));
1061
+ restInInterval = _context10.sent;
1062
+ this.printLogMessage("4484121, \u8D70\u5230\u4E00\u5761\u7761\u89BA\u5340 enableOfTaskSleepByInterval:".concat(this.enableOfTaskSleepByInterval, " || ").concat(restInInterval, " ms"));
1033
1063
 
1034
- if (this.isRunning()) {
1035
- _context11.next = 9;
1064
+ case 6:
1065
+ if (!(this.isRunning() && !this.isExecutingQueueFull())) {
1066
+ _context10.next = 18;
1036
1067
  break;
1037
1068
  }
1038
1069
 
1039
- _index2.utiller.appendInfo("".concat(this.getPoollerLogFormat(" Dispatcher \u7761\u8D77\u4F86\u4E4B\u5F8C, \u9047\u5230this.isTaskRunning === true, \u6240\u4EE5\u5C31\u7D50\u675F\u9019\u500BDispatch")));
1040
-
1041
- return _context11.abrupt("return");
1042
-
1043
- case 9:
1044
1070
  taskInfo = this.getTaskInfoDependOnPriority();
1045
1071
 
1046
- if (taskInfo) {
1047
- promise = this.taskWrapper(taskInfo.task, taskInfo.hash);
1048
- this.removeTaskMapByHash(taskInfo.hash);
1049
- this.appendToExecuteQueue(taskInfo.hash, promise);
1072
+ if (!taskInfo) {
1073
+ _context10.next = 14;
1074
+ break;
1050
1075
  }
1051
1076
 
1052
- case 11:
1077
+ promise = this.taskWrapper(taskInfo.task, taskInfo.hash);
1078
+ this.removeTaskMapByHash(taskInfo.hash);
1079
+ this.appendTaskToExecuteQueue(taskInfo.hash, promise);
1080
+ _context10.next = 15;
1081
+ break;
1082
+
1083
+ case 14:
1084
+ return _context10.abrupt("break", 18);
1085
+
1086
+ case 15:
1087
+ this.printLogMessage("848451 \u662F\u4E0D\u662F\u5728\u9019\u88E1\u7121\u9650\u8FF4\u5708\u8DD1\u8DD1\u8DD1", true);
1088
+ _context10.next = 6;
1089
+ break;
1090
+
1091
+ case 18:
1053
1092
  case "end":
1054
- return _context11.stop();
1093
+ return _context10.stop();
1055
1094
  }
1056
1095
  }
1057
- }, _callee11, this);
1096
+ }, _callee10, this);
1058
1097
  }));
1059
1098
 
1060
1099
  function syncTaskDispatcher() {
@@ -1068,106 +1107,117 @@ var InfinitePool = /*#__PURE__*/function () {
1068
1107
  value:
1069
1108
  /** 如果有function 就代表是一個需要回傳result的task, task在線等的意思*/
1070
1109
  function isWait4ResultTask(hash) {
1071
- return this.hashCallbackMapOfWaiting4Result[hash] !== undefined;
1110
+ return this.mapOfHashNCallbackWrapper[hash] !== undefined;
1072
1111
  }
1073
1112
  }, {
1074
1113
  key: "exampleOfWait4ResultAndRunInBackground",
1075
1114
  value:
1115
+ /** following function are examples **/
1116
+
1117
+ /** following function are examples **/
1118
+
1119
+ /** following function are examples **/
1120
+
1121
+ /** following function are examples **/
1122
+
1123
+ /** following function are examples **/
1124
+
1076
1125
  /** following function are examples **/
1077
1126
  function () {
1078
- var _exampleOfWait4ResultAndRunInBackground = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
1127
+ var _exampleOfWait4ResultAndRunInBackground = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
1079
1128
  var pool, asyncTask, startTimoutTask;
1080
- return _regenerator["default"].wrap(function _callee14$(_context14) {
1129
+ return _regenerator["default"].wrap(function _callee13$(_context13) {
1081
1130
  while (1) {
1082
- switch (_context14.prev = _context14.next) {
1131
+ switch (_context13.prev = _context13.next) {
1083
1132
  case 0:
1084
1133
  startTimoutTask = function _startTimoutTask(delayTime, taskSpendTime, sign) {
1085
1134
  var priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "low";
1086
- setTimeout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
1135
+ setTimeout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
1087
1136
  var printSign;
1088
- return _regenerator["default"].wrap(function _callee13$(_context13) {
1137
+ return _regenerator["default"].wrap(function _callee12$(_context12) {
1089
1138
  while (1) {
1090
- switch (_context13.prev = _context13.next) {
1139
+ switch (_context12.prev = _context12.next) {
1091
1140
  case 0:
1092
- _context13.prev = 0;
1093
- _context13.next = 3;
1141
+ _context12.prev = 0;
1142
+ _context12.next = 3;
1094
1143
  return pool.addTaskAndWait4Result(asyncTask(sign, taskSpendTime), priority);
1095
1144
 
1096
1145
  case 3:
1097
- printSign = _context13.sent;
1146
+ printSign = _context12.sent;
1098
1147
 
1099
1148
  _index2.utiller.appendInfo("answer => ", printSign);
1100
1149
 
1101
- _context13.next = 10;
1150
+ _context12.next = 10;
1102
1151
  break;
1103
1152
 
1104
1153
  case 7:
1105
- _context13.prev = 7;
1106
- _context13.t0 = _context13["catch"](0);
1154
+ _context12.prev = 7;
1155
+ _context12.t0 = _context12["catch"](0);
1107
1156
 
1108
- _index2.utiller.appendError("sign ".concat(sign, " perform fail"), _context13.t0.message);
1157
+ _index2.utiller.appendError("sign ".concat(sign, " perform fail"), _context12.t0.message);
1109
1158
 
1110
1159
  case 10:
1111
1160
  case "end":
1112
- return _context13.stop();
1161
+ return _context12.stop();
1113
1162
  }
1114
1163
  }
1115
- }, _callee13, null, [[0, 7]]);
1164
+ }, _callee12, null, [[0, 7]]);
1116
1165
  })), delayTime);
1117
1166
  };
1118
1167
 
1119
1168
  asyncTask = function _asyncTask(sign) {
1120
1169
  var taskSpend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
1121
- return /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
1122
- return _regenerator["default"].wrap(function _callee12$(_context12) {
1170
+ return /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
1171
+ return _regenerator["default"].wrap(function _callee11$(_context11) {
1123
1172
  while (1) {
1124
- switch (_context12.prev = _context12.next) {
1173
+ switch (_context11.prev = _context11.next) {
1125
1174
  case 0:
1126
- _context12.next = 2;
1175
+ _context11.next = 2;
1127
1176
  return _index2.utiller.syncDelay(taskSpend);
1128
1177
 
1129
1178
  case 2:
1130
- return _context12.abrupt("return", sign);
1179
+ return _context11.abrupt("return", sign);
1131
1180
 
1132
1181
  case 3:
1133
1182
  case "end":
1134
- return _context12.stop();
1183
+ return _context11.stop();
1135
1184
  }
1136
1185
  }
1137
- }, _callee12);
1186
+ }, _callee11);
1138
1187
  }));
1139
1188
  };
1140
1189
 
1141
- pool = new InfinitePool(1);
1190
+ pool = new InfinitePool(1, "david").runByEachTaskInBackGround();
1142
1191
  pool.enableTaskTimeout(true, 3000);
1143
1192
  startTimoutTask(0, 1000, "A", "low");
1144
- startTimoutTask(35, 1000, "C", "high");
1145
- startTimoutTask(500, 3000, "B", "low");
1193
+ startTimoutTask(1000, 1000, "C", "low");
1194
+ startTimoutTask(1000, 1000, "G", "high");
1195
+ startTimoutTask(500, 4000, "B", "low");
1146
1196
  startTimoutTask(3000, 1000, "D", "medium");
1147
1197
  startTimoutTask(10000, 2000, "E", "medium");
1148
1198
 
1149
- case 9:
1199
+ case 10:
1150
1200
  if (!pool.isRunning()) {
1151
- _context14.next = 15;
1201
+ _context13.next = 17;
1152
1202
  break;
1153
1203
  }
1154
1204
 
1155
- _index2.utiller.appendInfo("system is running"); // pool.showState();
1156
-
1205
+ _index2.utiller.appendInfo("system is running");
1157
1206
 
1158
- _context14.next = 13;
1207
+ pool.showState();
1208
+ _context13.next = 15;
1159
1209
  return _index2.utiller.syncDelay(5000);
1160
1210
 
1161
- case 13:
1162
- _context14.next = 9;
1211
+ case 15:
1212
+ _context13.next = 10;
1163
1213
  break;
1164
1214
 
1165
- case 15:
1215
+ case 17:
1166
1216
  case "end":
1167
- return _context14.stop();
1217
+ return _context13.stop();
1168
1218
  }
1169
1219
  }
1170
- }, _callee14);
1220
+ }, _callee13);
1171
1221
  }));
1172
1222
 
1173
1223
  function exampleOfWait4ResultAndRunInBackground() {
@@ -1179,45 +1229,45 @@ var InfinitePool = /*#__PURE__*/function () {
1179
1229
  }, {
1180
1230
  key: "exampleOfRunInBackgroundInfinite",
1181
1231
  value: function () {
1182
- var _exampleOfRunInBackgroundInfinite = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
1232
+ var _exampleOfRunInBackgroundInfinite = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
1183
1233
  var myAsyncTask, _myAsyncTask, pool;
1184
1234
 
1185
- return _regenerator["default"].wrap(function _callee17$(_context17) {
1235
+ return _regenerator["default"].wrap(function _callee16$(_context16) {
1186
1236
  while (1) {
1187
- switch (_context17.prev = _context17.next) {
1237
+ switch (_context16.prev = _context16.next) {
1188
1238
  case 0:
1189
1239
  _myAsyncTask = function _myAsyncTask3() {
1190
- _myAsyncTask = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
1240
+ _myAsyncTask = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
1191
1241
  var taskSpend, sign;
1192
- return _regenerator["default"].wrap(function _callee16$(_context16) {
1242
+ return _regenerator["default"].wrap(function _callee15$(_context15) {
1193
1243
  while (1) {
1194
- switch (_context16.prev = _context16.next) {
1244
+ switch (_context15.prev = _context15.next) {
1195
1245
  case 0:
1196
1246
  taskSpend = _index2.utiller.getRandomValue(1000, 1000);
1197
1247
  sign = _index2.utiller.getRandomHash(15);
1198
1248
 
1199
1249
  if (!_index2.utiller.isOdd(taskSpend)) {
1200
- _context16.next = 4;
1250
+ _context15.next = 4;
1201
1251
  break;
1202
1252
  }
1203
1253
 
1204
1254
  throw new Error("45100 Oops, ".concat(taskSpend, " is odd\u5566"));
1205
1255
 
1206
1256
  case 4:
1207
- _context16.next = 6;
1257
+ _context15.next = 6;
1208
1258
  return _index2.utiller.syncDelay(taskSpend);
1209
1259
 
1210
1260
  case 6:
1211
1261
  _index2.utiller.appendInfo(sign, taskSpend);
1212
1262
 
1213
- return _context16.abrupt("return", sign);
1263
+ return _context15.abrupt("return", sign);
1214
1264
 
1215
1265
  case 8:
1216
1266
  case "end":
1217
- return _context16.stop();
1267
+ return _context15.stop();
1218
1268
  }
1219
1269
  }
1220
- }, _callee16);
1270
+ }, _callee15);
1221
1271
  }));
1222
1272
  return _myAsyncTask.apply(this, arguments);
1223
1273
  };
@@ -1232,44 +1282,44 @@ var InfinitePool = /*#__PURE__*/function () {
1232
1282
  pool.setTaskFailHandler(function (error) {
1233
1283
  console.error(error.message);
1234
1284
  });
1235
- setTimeout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15() {
1236
- return _regenerator["default"].wrap(function _callee15$(_context15) {
1285
+ setTimeout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
1286
+ return _regenerator["default"].wrap(function _callee14$(_context14) {
1237
1287
  while (1) {
1238
- switch (_context15.prev = _context15.next) {
1288
+ switch (_context14.prev = _context14.next) {
1239
1289
  case 0:
1240
- _context15.next = 2;
1290
+ _context14.next = 2;
1241
1291
  return pool.stopInBackground();
1242
1292
 
1243
1293
  case 2:
1244
1294
  case "end":
1245
- return _context15.stop();
1295
+ return _context14.stop();
1246
1296
  }
1247
1297
  }
1248
- }, _callee15);
1298
+ }, _callee14);
1249
1299
  })), 100000);
1250
1300
 
1251
1301
  case 7:
1252
1302
  if (!pool.isRunning()) {
1253
- _context17.next = 14;
1303
+ _context16.next = 14;
1254
1304
  break;
1255
1305
  }
1256
1306
 
1257
1307
  _index2.utiller.appendInfo("system is running");
1258
1308
 
1259
- _context17.next = 11;
1309
+ _context16.next = 11;
1260
1310
  return _index2.utiller.syncDelay(3000);
1261
1311
 
1262
1312
  case 11:
1263
1313
  pool.showState();
1264
- _context17.next = 7;
1314
+ _context16.next = 7;
1265
1315
  break;
1266
1316
 
1267
1317
  case 14:
1268
1318
  case "end":
1269
- return _context17.stop();
1319
+ return _context16.stop();
1270
1320
  }
1271
1321
  }
1272
- }, _callee17);
1322
+ }, _callee16);
1273
1323
  }));
1274
1324
 
1275
1325
  function exampleOfRunInBackgroundInfinite() {
@@ -1281,33 +1331,33 @@ var InfinitePool = /*#__PURE__*/function () {
1281
1331
  }, {
1282
1332
  key: "exampleOfRunInfinite",
1283
1333
  value: function () {
1284
- var _exampleOfRunInfinite = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19() {
1285
- return _regenerator["default"].wrap(function _callee19$(_context19) {
1334
+ var _exampleOfRunInfinite = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
1335
+ return _regenerator["default"].wrap(function _callee18$(_context18) {
1286
1336
  while (1) {
1287
- switch (_context19.prev = _context19.next) {
1337
+ switch (_context18.prev = _context18.next) {
1288
1338
  case 0:
1289
- _context19.next = 2;
1290
- return new InfinitePool(3).runInInfinite( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18() {
1291
- return _regenerator["default"].wrap(function _callee18$(_context18) {
1339
+ _context18.next = 2;
1340
+ return new InfinitePool(3).runInInfinite( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17() {
1341
+ return _regenerator["default"].wrap(function _callee17$(_context17) {
1292
1342
  while (1) {
1293
- switch (_context18.prev = _context18.next) {
1343
+ switch (_context17.prev = _context17.next) {
1294
1344
  case 0:
1295
1345
  console.log("1000");
1296
1346
 
1297
1347
  case 1:
1298
1348
  case "end":
1299
- return _context18.stop();
1349
+ return _context17.stop();
1300
1350
  }
1301
1351
  }
1302
- }, _callee18);
1352
+ }, _callee17);
1303
1353
  })), 1000);
1304
1354
 
1305
1355
  case 2:
1306
1356
  case "end":
1307
- return _context19.stop();
1357
+ return _context18.stop();
1308
1358
  }
1309
1359
  }
1310
- }, _callee19);
1360
+ }, _callee18);
1311
1361
  }));
1312
1362
 
1313
1363
  function exampleOfRunInfinite() {
@@ -1319,20 +1369,20 @@ var InfinitePool = /*#__PURE__*/function () {
1319
1369
  }, {
1320
1370
  key: "exampleOfRunByParamInBackground",
1321
1371
  value: function () {
1322
- var _exampleOfRunByParamInBackground = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
1372
+ var _exampleOfRunByParamInBackground = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee20() {
1323
1373
  var pool;
1324
- return _regenerator["default"].wrap(function _callee21$(_context21) {
1374
+ return _regenerator["default"].wrap(function _callee20$(_context20) {
1325
1375
  while (1) {
1326
- switch (_context21.prev = _context21.next) {
1376
+ switch (_context20.prev = _context20.next) {
1327
1377
  case 0:
1328
1378
  pool = new InfinitePool(2);
1329
1379
  pool.runByParamInBackground( /*#__PURE__*/function () {
1330
- var _ref12 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee20(param) {
1331
- return _regenerator["default"].wrap(function _callee20$(_context20) {
1380
+ var _ref11 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19(param) {
1381
+ return _regenerator["default"].wrap(function _callee19$(_context19) {
1332
1382
  while (1) {
1333
- switch (_context20.prev = _context20.next) {
1383
+ switch (_context19.prev = _context19.next) {
1334
1384
  case 0:
1335
- _context20.next = 2;
1385
+ _context19.next = 2;
1336
1386
  return _index2.utiller.syncDelayRandom();
1337
1387
 
1338
1388
  case 2:
@@ -1340,38 +1390,38 @@ var InfinitePool = /*#__PURE__*/function () {
1340
1390
 
1341
1391
  case 3:
1342
1392
  case "end":
1343
- return _context20.stop();
1393
+ return _context19.stop();
1344
1394
  }
1345
1395
  }
1346
- }, _callee20);
1396
+ }, _callee19);
1347
1397
  }));
1348
1398
 
1349
1399
  return function (_x5) {
1350
- return _ref12.apply(this, arguments);
1400
+ return _ref11.apply(this, arguments);
1351
1401
  };
1352
1402
  }(), "david", "susan", "golden", "weber", "kevin");
1353
1403
 
1354
1404
  case 2:
1355
1405
  if (!pool.isRunning()) {
1356
- _context21.next = 8;
1406
+ _context20.next = 8;
1357
1407
  break;
1358
1408
  }
1359
1409
 
1360
1410
  _index2.utiller.appendInfo("system is running");
1361
1411
 
1362
- _context21.next = 6;
1412
+ _context20.next = 6;
1363
1413
  return _index2.utiller.syncDelay(3000);
1364
1414
 
1365
1415
  case 6:
1366
- _context21.next = 2;
1416
+ _context20.next = 2;
1367
1417
  break;
1368
1418
 
1369
1419
  case 8:
1370
1420
  case "end":
1371
- return _context21.stop();
1421
+ return _context20.stop();
1372
1422
  }
1373
1423
  }
1374
- }, _callee21);
1424
+ }, _callee20);
1375
1425
  }));
1376
1426
 
1377
1427
  function exampleOfRunByParamInBackground() {
@@ -1383,20 +1433,20 @@ var InfinitePool = /*#__PURE__*/function () {
1383
1433
  }, {
1384
1434
  key: "exampleOfRunByTimesInBackground",
1385
1435
  value: function () {
1386
- var _exampleOfRunByTimesInBackground = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee23() {
1436
+ var _exampleOfRunByTimesInBackground = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee22() {
1387
1437
  var pool, count;
1388
- return _regenerator["default"].wrap(function _callee23$(_context23) {
1438
+ return _regenerator["default"].wrap(function _callee22$(_context22) {
1389
1439
  while (1) {
1390
- switch (_context23.prev = _context23.next) {
1440
+ switch (_context22.prev = _context22.next) {
1391
1441
  case 0:
1392
1442
  pool = new InfinitePool(1);
1393
1443
  count = 0;
1394
- pool.runByTimesInBackground( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee22() {
1395
- return _regenerator["default"].wrap(function _callee22$(_context22) {
1444
+ pool.runByTimesInBackground( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee21() {
1445
+ return _regenerator["default"].wrap(function _callee21$(_context21) {
1396
1446
  while (1) {
1397
- switch (_context22.prev = _context22.next) {
1447
+ switch (_context21.prev = _context21.next) {
1398
1448
  case 0:
1399
- _context22.next = 2;
1449
+ _context21.next = 2;
1400
1450
  return _index2.utiller.syncDelayRandom();
1401
1451
 
1402
1452
  case 2:
@@ -1405,33 +1455,33 @@ var InfinitePool = /*#__PURE__*/function () {
1405
1455
 
1406
1456
  case 4:
1407
1457
  case "end":
1408
- return _context22.stop();
1458
+ return _context21.stop();
1409
1459
  }
1410
1460
  }
1411
- }, _callee22);
1461
+ }, _callee21);
1412
1462
  })), 10);
1413
1463
 
1414
1464
  case 3:
1415
1465
  if (!pool.isRunning()) {
1416
- _context23.next = 9;
1466
+ _context22.next = 9;
1417
1467
  break;
1418
1468
  }
1419
1469
 
1420
1470
  _index2.utiller.appendInfo("system is running");
1421
1471
 
1422
- _context23.next = 7;
1472
+ _context22.next = 7;
1423
1473
  return _index2.utiller.syncDelay(3000);
1424
1474
 
1425
1475
  case 7:
1426
- _context23.next = 3;
1476
+ _context22.next = 3;
1427
1477
  break;
1428
1478
 
1429
1479
  case 9:
1430
1480
  case "end":
1431
- return _context23.stop();
1481
+ return _context22.stop();
1432
1482
  }
1433
1483
  }
1434
- }, _callee23);
1484
+ }, _callee22);
1435
1485
  }));
1436
1486
 
1437
1487
  function exampleOfRunByTimesInBackground() {
@@ -1443,43 +1493,48 @@ var InfinitePool = /*#__PURE__*/function () {
1443
1493
  }, {
1444
1494
  key: "exampleOfRunByParam",
1445
1495
  value: function () {
1446
- var _exampleOfRunByParam = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee25() {
1496
+ var _exampleOfRunByParam = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee24() {
1447
1497
  var oneToTen, pool;
1448
- return _regenerator["default"].wrap(function _callee25$(_context25) {
1498
+ return _regenerator["default"].wrap(function _callee24$(_context24) {
1449
1499
  while (1) {
1450
- switch (_context25.prev = _context25.next) {
1500
+ switch (_context24.prev = _context24.next) {
1451
1501
  case 0:
1452
1502
  oneToTen = _lodash["default"].range(1, 10);
1453
- pool = new InfinitePool(1);
1454
- pool.enableTaskSleepInterval(true, 1000);
1455
- _context25.next = 5;
1456
- return pool.runByParams(oneToTen, /*#__PURE__*/function () {
1457
- var _ref14 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee24(param) {
1458
- return _regenerator["default"].wrap(function _callee24$(_context24) {
1503
+ pool = new InfinitePool(2);
1504
+ _context24.next = 4;
1505
+ return pool.runByParams.apply(pool, [/*#__PURE__*/function () {
1506
+ var _ref13 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee23(param) {
1507
+ var ms;
1508
+ return _regenerator["default"].wrap(function _callee23$(_context23) {
1459
1509
  while (1) {
1460
- switch (_context24.prev = _context24.next) {
1510
+ switch (_context23.prev = _context23.next) {
1461
1511
  case 0:
1462
- console.log(param);
1512
+ _context23.next = 2;
1513
+ return _index2.utiller.syncDelayRandom();
1514
+
1515
+ case 2:
1516
+ ms = _context23.sent;
1517
+ console.log(param, "".concat(ms, " ms"));
1463
1518
 
1464
- case 1:
1519
+ case 4:
1465
1520
  case "end":
1466
- return _context24.stop();
1521
+ return _context23.stop();
1467
1522
  }
1468
1523
  }
1469
- }, _callee24);
1524
+ }, _callee23);
1470
1525
  }));
1471
1526
 
1472
1527
  return function (_x6) {
1473
- return _ref14.apply(this, arguments);
1528
+ return _ref13.apply(this, arguments);
1474
1529
  };
1475
- }());
1530
+ }()].concat((0, _toConsumableArray2["default"])(oneToTen)));
1476
1531
 
1477
- case 5:
1532
+ case 4:
1478
1533
  case "end":
1479
- return _context25.stop();
1534
+ return _context24.stop();
1480
1535
  }
1481
1536
  }
1482
- }, _callee25);
1537
+ }, _callee24);
1483
1538
  }));
1484
1539
 
1485
1540
  function exampleOfRunByParam() {
@@ -1491,21 +1546,21 @@ var InfinitePool = /*#__PURE__*/function () {
1491
1546
  }, {
1492
1547
  key: "exampleOfRunByCount",
1493
1548
  value: function () {
1494
- var _exampleOfRunByCount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee27() {
1549
+ var _exampleOfRunByCount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee26() {
1495
1550
  var pool, time;
1496
- return _regenerator["default"].wrap(function _callee27$(_context27) {
1551
+ return _regenerator["default"].wrap(function _callee26$(_context26) {
1497
1552
  while (1) {
1498
- switch (_context27.prev = _context27.next) {
1553
+ switch (_context26.prev = _context26.next) {
1499
1554
  case 0:
1500
1555
  pool = new InfinitePool(1);
1501
1556
  time = 0;
1502
- _context27.next = 4;
1503
- return pool.runByTimes(20, /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee26() {
1504
- return _regenerator["default"].wrap(function _callee26$(_context26) {
1557
+ _context26.next = 4;
1558
+ return pool.runByTimes(20, /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee25() {
1559
+ return _regenerator["default"].wrap(function _callee25$(_context25) {
1505
1560
  while (1) {
1506
- switch (_context26.prev = _context26.next) {
1561
+ switch (_context25.prev = _context25.next) {
1507
1562
  case 0:
1508
- _context26.next = 2;
1563
+ _context25.next = 2;
1509
1564
  return _index2.utiller.syncDelay(1000);
1510
1565
 
1511
1566
  case 2:
@@ -1514,18 +1569,18 @@ var InfinitePool = /*#__PURE__*/function () {
1514
1569
 
1515
1570
  case 4:
1516
1571
  case "end":
1517
- return _context26.stop();
1572
+ return _context25.stop();
1518
1573
  }
1519
1574
  }
1520
- }, _callee26);
1575
+ }, _callee25);
1521
1576
  })));
1522
1577
 
1523
1578
  case 4:
1524
1579
  case "end":
1525
- return _context27.stop();
1580
+ return _context26.stop();
1526
1581
  }
1527
1582
  }
1528
- }, _callee27);
1583
+ }, _callee26);
1529
1584
  }));
1530
1585
 
1531
1586
  function exampleOfRunByCount() {
@@ -1534,6 +1589,170 @@ var InfinitePool = /*#__PURE__*/function () {
1534
1589
 
1535
1590
  return exampleOfRunByCount;
1536
1591
  }()
1592
+ }, {
1593
+ key: "exampleOfInfiniteUnStopLoopingIssue",
1594
+ value: function () {
1595
+ var _exampleOfInfiniteUnStopLoopingIssue = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee28() {
1596
+ var persistTone, _persistTone, poollers, pool, isRequiredTerminate, random, _iterator6, _step6, pooller;
1597
+
1598
+ return _regenerator["default"].wrap(function _callee28$(_context28) {
1599
+ while (1) {
1600
+ switch (_context28.prev = _context28.next) {
1601
+ case 0:
1602
+ _persistTone = function _persistTone3() {
1603
+ _persistTone = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee27() {
1604
+ var sign;
1605
+ return _regenerator["default"].wrap(function _callee27$(_context27) {
1606
+ while (1) {
1607
+ switch (_context27.prev = _context27.next) {
1608
+ case 0:
1609
+ _context27.prev = 0;
1610
+ sign = _index2.utiller.getRandomHash(20);
1611
+ _context27.next = 4;
1612
+ return _index2.utiller.syncDelay(1000);
1613
+
1614
+ case 4:
1615
+ _context27.t0 = _index2.utiller;
1616
+ _context27.t1 = "\u6C92\u6709TONE\u53EF\u4EE5\u4E0B\u8F09\u4E86....\u96A8\u6A5F\u7761\u500B";
1617
+ _context27.next = 8;
1618
+ return _index2.utiller.syncDelayRandom(1500, 3500);
1619
+
1620
+ case 8:
1621
+ _context27.t2 = _context27.sent;
1622
+ _context27.t3 = _context27.t1.concat.call(_context27.t1, _context27.t2);
1623
+
1624
+ _context27.t0.appendInfo.call(_context27.t0, _context27.t3);
1625
+
1626
+ return _context27.abrupt("return", "\u4EFB\u52D9ID:".concat(sign));
1627
+
1628
+ case 14:
1629
+ _context27.prev = 14;
1630
+ _context27.t4 = _context27["catch"](0);
1631
+
1632
+ _index2.utiller.appendError(_context27.t4.message);
1633
+
1634
+ case 17:
1635
+ case "end":
1636
+ return _context27.stop();
1637
+ }
1638
+ }
1639
+ }, _callee27, null, [[0, 14]]);
1640
+ }));
1641
+ return _persistTone.apply(this, arguments);
1642
+ };
1643
+
1644
+ persistTone = function _persistTone2() {
1645
+ return _persistTone.apply(this, arguments);
1646
+ };
1647
+
1648
+ poollers = [];
1649
+ pool = new InfinitePool(2);
1650
+ pool.setPoolId("tone fetch");
1651
+ pool.setIgnoreFirstRun(false);
1652
+ pool.runInfiniteInBackground(persistTone, 3000);
1653
+ pool.setTaskFailHandler(function (error) {
1654
+ return _index2.utiller.appendError("5165 error ".concat(error.message));
1655
+ });
1656
+ poollers.push(pool);
1657
+ isRequiredTerminate = false;
1658
+ setTimeout(function () {
1659
+ isRequiredTerminate = true;
1660
+ }, 10000);
1661
+
1662
+ case 11:
1663
+ if (!true) {
1664
+ _context28.next = 44;
1665
+ break;
1666
+ }
1667
+
1668
+ _index2.utiller.exeAll(poollers, function (each) {
1669
+ return each.showState();
1670
+ });
1671
+
1672
+ _context28.next = 15;
1673
+ return _index2.utiller.syncDelayRandom();
1674
+
1675
+ case 15:
1676
+ random = _context28.sent;
1677
+
1678
+ _index2.utiller.appendInfo("\u4E3B\u7DDA\u7A0B\u9084\u5728\u52AA\u4E2D\u5DE5\u4F5C\u4E2D, \u4F11\u606F\u4E00\u6BC0\u5152 ".concat(random, " mms"));
1679
+
1680
+ _context28.next = 19;
1681
+ return _index2.utiller.syncDelay(random);
1682
+
1683
+ case 19:
1684
+ if (!isRequiredTerminate) {
1685
+ _context28.next = 42;
1686
+ break;
1687
+ }
1688
+
1689
+ _index2.utiller.appendInfo("\u4E3B\u7DDA\u7A0B\u6536\u5230\u95DC\u9589\u6307\u4EE4...");
1690
+
1691
+ _iterator6 = _createForOfIteratorHelper(poollers);
1692
+ _context28.prev = 22;
1693
+
1694
+ _iterator6.s();
1695
+
1696
+ case 24:
1697
+ if ((_step6 = _iterator6.n()).done) {
1698
+ _context28.next = 33;
1699
+ break;
1700
+ }
1701
+
1702
+ pooller = _step6.value;
1703
+
1704
+ _index2.utiller.appendInfo("POOLER ".concat(pooller.getPoolId(), " \u6B63\u5728\u95DC\u9589\u4E2D"));
1705
+
1706
+ _context28.next = 29;
1707
+ return pooller.stopInBackground();
1708
+
1709
+ case 29:
1710
+ pooller.showState();
1711
+
1712
+ _index2.utiller.appendInfo("POOLER ".concat(pooller.getPoolId(), " \u95DC\u9589\u6210\u529F!"));
1713
+
1714
+ case 31:
1715
+ _context28.next = 24;
1716
+ break;
1717
+
1718
+ case 33:
1719
+ _context28.next = 38;
1720
+ break;
1721
+
1722
+ case 35:
1723
+ _context28.prev = 35;
1724
+ _context28.t0 = _context28["catch"](22);
1725
+
1726
+ _iterator6.e(_context28.t0);
1727
+
1728
+ case 38:
1729
+ _context28.prev = 38;
1730
+
1731
+ _iterator6.f();
1732
+
1733
+ return _context28.finish(38);
1734
+
1735
+ case 41:
1736
+ return _context28.abrupt("break", 44);
1737
+
1738
+ case 42:
1739
+ _context28.next = 11;
1740
+ break;
1741
+
1742
+ case 44:
1743
+ case "end":
1744
+ return _context28.stop();
1745
+ }
1746
+ }
1747
+ }, _callee28, null, [[22, 35, 38, 41]]);
1748
+ }));
1749
+
1750
+ function exampleOfInfiniteUnStopLoopingIssue() {
1751
+ return _exampleOfInfiniteUnStopLoopingIssue.apply(this, arguments);
1752
+ }
1753
+
1754
+ return exampleOfInfiniteUnStopLoopingIssue;
1755
+ }()
1537
1756
  }]);
1538
1757
  return InfinitePool;
1539
1758
  }();