mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Storage Service Write: Improved conflict handling
This commit is contained in:
14
ts/util/JobQueue.ts
Normal file
14
ts/util/JobQueue.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import PQueue from 'p-queue';
|
||||
import createTaskWithTimeout from '../textsecure/TaskWithTimeout';
|
||||
|
||||
function createJobQueue(label: string) {
|
||||
const jobQueue = new PQueue({ concurrency: 1 });
|
||||
|
||||
return (job: () => Promise<void>, id = '') => {
|
||||
const taskWithTimeout = createTaskWithTimeout(job, `${label} ${id}`);
|
||||
|
||||
return jobQueue.add(taskWithTimeout);
|
||||
};
|
||||
}
|
||||
|
||||
export const storageJobQueue = createJobQueue('storageService');
|
||||
Reference in New Issue
Block a user