Initializes the shared worker pool. Should be called by subclasses via super.initialize() or independently.
async initialize(): Promise<void> {
if (this.initialized) {
return;
}
try {
const pool = getGenericWorkerPool();
await pool.initialize();
this.initialized = true;
console.info(`[${this.getPoolName()}] Pool initialized`);
} catch (error) {
console.warn(`[${this.getPoolName()}] Failed to initialize pool:`, error);
// Still mark as initialized to use main thread fallback
this.initialized = true;
}
}
Returns initialization and availability stats.
Status object
Detects duplicate AniList IDs from matches using workers when available. Falls back to main thread when worker execution is not possible.
Candidate matches to evaluate.
Duplicate detection result with timing metadata.
async detectDuplicates(
matches: MangaMatchResult[],
): Promise<DuplicateDetectionResult> {
const taskId = generateUniqueTaskId();
await this.ensureInitialized();
return this.executeWithFallback(
() => this.executeOnWorker(taskId, matches),
() => this.executeOnMainThread(matches),
taskId,
);
}
Coordinates duplicate detection tasks across workers with main-thread fallback.
Source