mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 16:23:20 +01:00
16 lines
479 B
TypeScript
16 lines
479 B
TypeScript
// Copyright 2020 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import PQueue from 'p-queue';
|
|
import { runTaskWithTimeout } from '../textsecure/TaskWithTimeout.std.ts';
|
|
|
|
function createJobQueue(label: string) {
|
|
const jobQueue = new PQueue({ concurrency: 1 });
|
|
|
|
return (job: () => Promise<void>, id = '') => {
|
|
return jobQueue.add(() => runTaskWithTimeout(job, `${label} ${id}`));
|
|
};
|
|
}
|
|
|
|
export const storageJobQueue = createJobQueue('storageService');
|