Non-blocking worker pool initialization for the renderer process. Loads worker pools in parallel with UI rendering to improve startup performance.

export async function initializeWorkerPoolsAsync(): Promise<void> {
try {
// Initialize the main generic worker pool (core infrastructure)
const { getGenericWorkerPool } = await import("./core/worker-pool");
const genericPool = getGenericWorkerPool();
await genericPool.initialize();

// Initialize data processing worker pools
const { getCSVWorkerPool } = await import(
"./data-processing/csv-worker-pool"
);
await getCSVWorkerPool().initialize();

const { getFilterWorkerPool } = await import(
"./data-processing/filter-worker-pool"
);
await getFilterWorkerPool().initialize();

const { getJSONSerializationWorkerPool } = await import(
"./data-processing/json-serialization-worker-pool"
);
await getJSONSerializationWorkerPool().initialize();

// Initialize statistics worker pools
const { getStatisticsWorkerPool } = await import(
"./statistics/statistics-worker-pool"
);
await getStatisticsWorkerPool().initialize();

const { getReadingHistoryWorkerPool } = await import(
"./statistics/reading-history-worker-pool"
);
await getReadingHistoryWorkerPool().initialize();

const { getTitleNormalizationPool } = await import(
"./statistics/title-normalization-worker-pool"
);
await getTitleNormalizationPool().initialize();

const { getDuplicateDetectionWorkerPool } = await import(
"./statistics/duplicate-worker-pool"
);
await getDuplicateDetectionWorkerPool().initialize();

// Initialize UI worker pools
const { getDataTableWorkerPool } = await import(
"./ui/data-table-worker-pool"
);
await getDataTableWorkerPool().initialize();

console.info("[WorkerInit] ✅ All worker pools initialized successfully");
} catch (error) {
console.warn(
"[WorkerInit] ⚠️ Worker pool initialization failed (will fall back to main thread):",
error instanceof Error ? error.message : String(error),
);
// Non-critical: if workers fail, the app falls back to main thread execution
// Re-throw to allow error handling in the caller
throw error;
}
}

Functions

initializeWorkerPoolsAsync