()
| 84 | } |
| 85 | |
| 86 | process () { |
| 87 | if (this.queue.length <= 0) { |
| 88 | this.stop() |
| 89 | this.lock = false |
| 90 | return |
| 91 | } |
| 92 | |
| 93 | const task = this.queue.shift() |
| 94 | this.taskMap.delete(task.id) |
| 95 | |
| 96 | const finishTask = () => { |
| 97 | this.lock = false |
| 98 | setImmediate(() => { |
| 99 | this.emit(QueueEvent.Finish) |
| 100 | }) |
| 101 | } |
| 102 | task.processingFunc().then(finishTask).catch(finishTask) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | exports.ProcessQueue = ProcessQueue |
no test coverage detected