/** * Concurrency module - Classes for managing concurrent operations */ import type { ConcurrencyOptions } from './types.js'; /** * Semaphore for limiting concurrent operations */ export declare class Semaphore { private permits; private waitQueue; constructor(permits: number); /** * Acquire a permit, waiting if necessary */ acquire(priority?: number): Promise; /** * Release a permit */ release(): void; /** * Get available permits */ get available(): number; /** * Get queue length */ get queueLength(): number; } /** * Domain-based rate limiter to prevent overwhelming single domains */ export declare class DomainRateLimiter { private lastRequestTime; private readonly minDelayMs; constructor(minDelayMs?: number); /** * Wait if needed to respect rate limit for a domain */ waitForDomain(domain: string): Promise; /** * Extract domain from URL */ static extractDomain(url: string): string; private sleep; /** * Clear tracked domains */ clear(): void; } /** * Controller for managing concurrent operations with domain rate limiting */ export declare class ConcurrencyController { private semaphore; private rateLimiter; private abortController; private readonly timeout; constructor(options?: Partial); /** * Run tasks with concurrency control */ run(items: T[], task: (item: T, signal?: AbortSignal) => Promise, options?: { onResult?: (result: R, item: T) => void; onError?: (error: Error, item: T) => void; getDomain?: (item: T) => string; signal?: AbortSignal; }): Promise; /** * Abort all running operations */ abort(): void; /** * Check if controller is aborted */ get isAborted(): boolean; /** * Reset the controller for reuse */ reset(): void; private runWithTimeout; } /** * Run tasks with concurrency control (standalone function) */ export declare function runWithConcurrency(items: T[], task: (item: T) => Promise, maxConcurrency?: number): Promise;