File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ class Queue {
6464 this . finish ( err , task ) ;
6565 if ( waiting . length > 0 ) {
6666 setTimeout ( ( ) => {
67- if ( ! this . paused ) this . takeNext ( ) ;
67+ if ( ! this . paused && waiting . length > 0 ) this . takeNext ( ) ;
6868 } , 0 ) ;
6969 }
7070 return ;
@@ -109,11 +109,13 @@ class Queue {
109109 return this ;
110110 }
111111 resume ( ) {
112- this . paused = false ;
113112 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+ }
116117 }
118+ this . paused = false ;
117119 return this ;
118120 }
119121}
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ class Queue {
6868 this . finish ( err , task ) ;
6969 if ( waiting . length > 0 ) {
7070 setTimeout ( ( ) => {
71- if ( this . paused && waiting . length > 0 ) this . takeNext ( ) ;
71+ if ( ! this . paused && waiting . length > 0 ) this . takeNext ( ) ;
7272 } , 0 ) ;
7373 }
7474 return ;
@@ -113,11 +113,13 @@ class Queue {
113113 return this ;
114114 }
115115 resume ( ) {
116- this . paused = false ;
117116 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+ }
120121 }
122+ this . paused = false ;
121123 return this ;
122124 }
123125 priority ( flag = true ) {
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ class Queue {
6969 this . finish ( err , task ) ;
7070 if ( waiting . length > 0 ) {
7171 setTimeout ( ( ) => {
72- if ( this . paused && waiting . length > 0 ) this . takeNext ( ) ;
72+ if ( ! this . paused && waiting . length > 0 ) this . takeNext ( ) ;
7373 } , 0 ) ;
7474 }
7575 return ;
@@ -115,11 +115,13 @@ class Queue {
115115 return this ;
116116 }
117117 resume ( ) {
118- this . paused = false ;
119118 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+ }
122123 }
124+ this . paused = false ;
123125 return this ;
124126 }
125127 priority ( flag = true ) {
You can’t perform that action at this time.
0 commit comments