@stackbit/utils
Version:
Stackbit utilities
18 lines • 761 B
TypeScript
export declare class Worker {
private promise;
private enqueued;
constructor();
schedule(jobFn: () => Promise<any>): Promise<any>;
/**
* Run one after another 2 calls of same jobFn, 3rd and next calls will be waiting for finishing 2nd and
* respond all together
* In case there are another jobFn called on the same worker - 2nd round of calls would be postponed to process next call
* to prevent dead lock
* @see https://user-images.githubusercontent.com/97896/90123842-1fea2f80-dd68-11ea-8462-d4f1cdc1749b.png
* @param {String} jobId
* @param {Function} jobFn
* @returns {Promise}
*/
enqueueOnce(jobId: string, jobFn: () => Promise<any>): Promise<any>;
}
//# sourceMappingURL=worker.d.ts.map