()
| 93 | } |
| 94 | |
| 95 | private processQueue(): void { |
| 96 | // Drain the entire queue - process all waiting requests with available workers |
| 97 | while (this.queue.length > 0) { |
| 98 | const worker = this.getAvailableWorker(); |
| 99 | if (!worker) { |
| 100 | return; // No workers available right now |
| 101 | } |
| 102 | |
| 103 | const request = this.queue.shift(); |
| 104 | if (!request) { |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | logger.debug(`Processing queued request (${this.queue.length} remaining)`); |
| 109 | |
| 110 | // Execute and attach queue processing to continue draining when done |
| 111 | worker |
| 112 | .call(request.functionName, request.args) |
| 113 | .then(request.resolve) |
| 114 | .catch(request.reject) |
| 115 | .finally(() => this.processQueue()); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | getWorkerCount(): number { |
| 120 | return this.workers.length; |
no test coverage detected