File tree 3 files changed +18
-12
lines changed
3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ class Queue {
64
64
this . finish ( err , task ) ;
65
65
if ( waiting . length > 0 ) {
66
66
setTimeout ( ( ) => {
67
- if ( ! this . paused ) this . takeNext ( ) ;
67
+ if ( ! this . paused && waiting . length > 0 ) this . takeNext ( ) ;
68
68
} , 0 ) ;
69
69
}
70
70
return ;
@@ -109,11 +109,13 @@ class Queue {
109
109
return this ;
110
110
}
111
111
resume ( ) {
112
- this . paused = false ;
113
112
if ( this . waiting . length > 0 ) {
114
- const hasChannel = this . count < this . concurrency ;
115
- if ( hasChannel ) this . takeNext ( ) ;
113
+ const channels = this . concurrency - this . count ;
114
+ for ( let i = 0 ; i < channels ; i ++ ) {
115
+ this . takeNext ( ) ;
116
+ }
116
117
}
118
+ this . paused = false ;
117
119
return this ;
118
120
}
119
121
}
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ class Queue {
68
68
this . finish ( err , task ) ;
69
69
if ( waiting . length > 0 ) {
70
70
setTimeout ( ( ) => {
71
- if ( this . paused && waiting . length > 0 ) this . takeNext ( ) ;
71
+ if ( ! this . paused && waiting . length > 0 ) this . takeNext ( ) ;
72
72
} , 0 ) ;
73
73
}
74
74
return ;
@@ -113,11 +113,13 @@ class Queue {
113
113
return this ;
114
114
}
115
115
resume ( ) {
116
- this . paused = false ;
117
116
if ( this . waiting . length > 0 ) {
118
- const hasChannel = this . count < this . concurrency ;
119
- if ( hasChannel ) this . takeNext ( ) ;
117
+ const channels = this . concurrency - this . count ;
118
+ for ( let i = 0 ; i < channels ; i ++ ) {
119
+ this . takeNext ( ) ;
120
+ }
120
121
}
122
+ this . paused = false ;
121
123
return this ;
122
124
}
123
125
priority ( flag = true ) {
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ class Queue {
69
69
this . finish ( err , task ) ;
70
70
if ( waiting . length > 0 ) {
71
71
setTimeout ( ( ) => {
72
- if ( this . paused && waiting . length > 0 ) this . takeNext ( ) ;
72
+ if ( ! this . paused && waiting . length > 0 ) this . takeNext ( ) ;
73
73
} , 0 ) ;
74
74
}
75
75
return ;
@@ -115,11 +115,13 @@ class Queue {
115
115
return this ;
116
116
}
117
117
resume ( ) {
118
- this . paused = false ;
119
118
if ( this . waiting . length > 0 ) {
120
- const hasChannel = this . count < this . concurrency ;
121
- if ( hasChannel ) this . takeNext ( ) ;
119
+ const channels = this . concurrency - this . count ;
120
+ for ( let i = 0 ; i < channels ; i ++ ) {
121
+ this . takeNext ( ) ;
122
+ }
122
123
}
124
+ this . paused = false ;
123
125
return this ;
124
126
}
125
127
priority ( flag = true ) {
You can’t perform that action at this time.
0 commit comments