Skip to content

Commit

Permalink
fix: 修复了所有任务完成提示重复的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
libudu committed Sep 13, 2022
1 parent 4bfdbf4 commit 23a0c73
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,22 @@ const options = {

const taskManager = {
taskList: [],
totalCount: 0,
finishCount: 0,
taskFinish: () => {
const task = taskManager.taskList.shift();
if(task) {
task();
} else {
}
taskManager.finishCount += 1;
if(taskManager.finishCount == taskManager.totalCount) {
console.log("所有任务处理完成!");
process.openStdin();
}
},
maxParallel: 20,
start: () => {
taskManager.totalCount = taskManager.taskList.length;
const initCount = taskManager.taskList.slice(0, taskManager.maxParallel).length;
for(let i = 0; i < initCount; i++) {
taskManager.taskList.shift()();
Expand Down

0 comments on commit 23a0c73

Please sign in to comment.