mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 08:13:37 +01:00
Simplify TaskWithTimeout
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
@@ -2,15 +2,13 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import PQueue from 'p-queue';
|
||||
import createTaskWithTimeout from '../textsecure/TaskWithTimeout.std.js';
|
||||
import { runTaskWithTimeout } from '../textsecure/TaskWithTimeout.std.js';
|
||||
|
||||
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);
|
||||
return jobQueue.add(() => runTaskWithTimeout(job, `${label} ${id}`));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user