()
| 81 | } |
| 82 | |
| 83 | workingRequest () { |
| 84 | while (this.workingList.length < this.limit && this.workList.length) { |
| 85 | const work = this.workList.shift() |
| 86 | this.workingList.push(work) |
| 87 | this.run(work) |
| 88 | } |
| 89 | // 对低优先级请求总有所保留,为之后的正常请求提供一个buffer |
| 90 | const buffer = parseInt((this.limit - this.workingList.length) * this.ratio, 10) || 1 |
| 91 | const limit = this.limit - buffer |
| 92 | while (this.workingList.length < limit && this.lowWorkList.length) { |
| 93 | const work = this.lowWorkList.shift() |
| 94 | this.workingList.push(work) |
| 95 | this.run(work) |
| 96 | } |
| 97 | this.flushing = false |
| 98 | } |
| 99 | |
| 100 | requestComplete (work) { |
| 101 | this.delWorkQueue(work) |
no test coverage detected