"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sequentialHTTPBroadcastFromWorker = exports.parallelHTTPBroadcastFromWorker = exports.processImageFromWorker = exports.downloadImageFromWorker = void 0;
const tslib_1 = require("tslib");
const path_1 = require("path");
const piscina_1 = tslib_1.__importDefault(require("piscina"));
const constants_1 = require("../../initializers/constants");
let downloadImageWorker;
function downloadImageFromWorker(options) {
    if (!downloadImageWorker) {
        downloadImageWorker = new piscina_1.default({
            filename: (0, path_1.join)(__dirname, 'workers', 'image-downloader.js'),
            concurrentTasksPerWorker: constants_1.WORKER_THREADS.DOWNLOAD_IMAGE.CONCURRENCY,
            maxThreads: constants_1.WORKER_THREADS.DOWNLOAD_IMAGE.MAX_THREADS
        });
    }
    return downloadImageWorker.run(options);
}
exports.downloadImageFromWorker = downloadImageFromWorker;
let processImageWorker;
function processImageFromWorker(options) {
    if (!processImageWorker) {
        processImageWorker = new piscina_1.default({
            filename: (0, path_1.join)(__dirname, 'workers', 'image-processor.js'),
            concurrentTasksPerWorker: constants_1.WORKER_THREADS.PROCESS_IMAGE.CONCURRENCY,
            maxThreads: constants_1.WORKER_THREADS.PROCESS_IMAGE.MAX_THREADS
        });
    }
    return processImageWorker.run(options);
}
exports.processImageFromWorker = processImageFromWorker;
let parallelHTTPBroadcastWorker;
function parallelHTTPBroadcastFromWorker(options) {
    if (!parallelHTTPBroadcastWorker) {
        parallelHTTPBroadcastWorker = new piscina_1.default({
            filename: (0, path_1.join)(__dirname, 'workers', 'http-broadcast.js'),
            concurrentTasksPerWorker: constants_1.JOB_CONCURRENCY['activitypub-http-broadcast-parallel'],
            maxThreads: 1
        });
    }
    return parallelHTTPBroadcastWorker.run(options);
}
exports.parallelHTTPBroadcastFromWorker = parallelHTTPBroadcastFromWorker;
let sequentialHTTPBroadcastWorker;
function sequentialHTTPBroadcastFromWorker(options) {
    if (!sequentialHTTPBroadcastWorker) {
        sequentialHTTPBroadcastWorker = new piscina_1.default({
            filename: (0, path_1.join)(__dirname, 'workers', 'http-broadcast.js'),
            concurrentTasksPerWorker: constants_1.JOB_CONCURRENCY['activitypub-http-broadcast'],
            maxThreads: 1
        });
    }
    return sequentialHTTPBroadcastWorker.run(options);
}
exports.sequentialHTTPBroadcastFromWorker = sequentialHTTPBroadcastFromWorker;
//# sourceMappingURL=parent-process.js.map