@@ -21,6 +21,11 @@ component singleton="true" {
2121 variables .apiTimeout = trim (variables .system .getenv (" FIXINATOR_API_TIMEOUT" ));
2222 }
2323
24+ variables .maxConcurrency = 8 ;
25+ if (! isNull (variables .system .getenv (" FIXINATOR_MAX_CONCURRENCY" ))) {
26+ variables .maxConcurrency = trim (variables .system .getenv (" FIXINATOR_MAX_CONCURRENCY" ));
27+ }
28+
2429 variables .clientUpdate = false ;
2530 variables .debugMode = false ;
2631
@@ -138,7 +143,15 @@ component singleton="true" {
138143 }
139144 if (server .keyExists (" lucee" )) {
140145 // run parallel on lucee
141- arrayEach (local .batches , processBatch , true , arrayLen (local .batches ));
146+ local .concurrency = arrayLen (local .batches );
147+ if (local .concurrency > variables .maxConcurrency ) {
148+ local .concurrency = variables .maxConcurrency ;
149+ }
150+ // use at least 2 threads, to allow progressbar to update
151+ if (hasProgressBar && local .concurrency < 2 ) {
152+ local .concurrency = 2 ;
153+ }
154+ arrayEach (local .batches , processBatch , true , local .concurrency );
142155 } else {
143156 arrayEach (local .batches , processBatch );
144157 }
@@ -204,6 +217,14 @@ component singleton="true" {
204217 variables .apiTimeout = arguments .apiTimeout ;
205218 }
206219
220+ public function getMaxConcurrency () {
221+ return variables .maxConcurrency ;
222+ }
223+
224+ public function setMaxConcurrency (numeric maxConcurrency ) {
225+ variables .maxConcurrency = arguments .maxConcurrency ;
226+ }
227+
207228 public function getLockTimeout () {
208229 return getAPITimeout () + 1 ;
209230 }
0 commit comments