chore: lint

This commit is contained in:
karishmas6
2024-06-12 20:09:31 +05:30
parent 779c1f66cc
commit 88620344f7

View File

@@ -5,22 +5,22 @@ export default class Concurrency {
/** /**
* Maximum number of workers running in parallel. If set to `null`, there is no limit. * Maximum number of workers running in parallel. If set to `null`, there is no limit.
*/ */
maxConcurrency : number = 1; maxConcurrency: number = 1;
/** /**
* Number of currently active workers. * Number of currently active workers.
*/ */
activeWorkers : number = 0; activeWorkers: number = 0;
/** /**
* Queue of jobs waiting to be completed. * Queue of jobs waiting to be completed.
*/ */
private jobQueue : Function[] = []; private jobQueue: Function[] = [];
/** /**
* "Resolve" callbacks of the waitForCompletion() promises. * "Resolve" callbacks of the waitForCompletion() promises.
*/ */
private waiting : Function[] = []; private waiting: Function[] = [];
/** /**
* Constructs a new instance of concurrency manager. * Constructs a new instance of concurrency manager.
@@ -33,7 +33,7 @@ export default class Concurrency {
/** /**
* Takes a waiting job out of the queue and runs it. * Takes a waiting job out of the queue and runs it.
*/ */
private runNextJob() : void { private runNextJob(): void {
const job = this.jobQueue.pop(); const job = this.jobQueue.pop();
if (job) { if (job) {
@@ -59,7 +59,7 @@ export default class Concurrency {
* but this is not guaranteed). * but this is not guaranteed).
* @param worker Async function to be executed (job to be processed). * @param worker Async function to be executed (job to be processed).
*/ */
addJob(job: () => Promise<any>) : void { addJob(job: () => Promise<any>): void {
// console.debug("Adding a worker!"); // console.debug("Adding a worker!");
this.jobQueue.push(job); this.jobQueue.push(job);
@@ -77,9 +77,9 @@ export default class Concurrency {
* it waits until at least one job is compeleted (can be "presubscribed"). * it waits until at least one job is compeleted (can be "presubscribed").
* @returns Promise, resolved after there is no running/waiting worker. * @returns Promise, resolved after there is no running/waiting worker.
*/ */
waitForCompletion() : Promise<void> { waitForCompletion(): Promise<void> {
return new Promise((res) => { return new Promise((res) => {
this.waiting.push(res); this.waiting.push(res);
}); });
} }
} }