mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 08:13:37 +01:00
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
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.js';
|
|
|
|
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');
|