import { CoValueCore } from "../exports.js"; import type { PeerID } from "../sync.js"; /** * Mode for enqueuing load requests: * - "high-priority" (default): high priority, processed in order * - "low-priority": processed after all high priority requests * - "immediate": bypasses the queue entirely, executes immediately */ export type LoadMode = "low-priority" | "immediate" | "high-priority"; export type LoadCompletionSource = "content" | "known"; /** * A queue that manages outgoing load requests with throttling. * * Features: * - Limits concurrent in-flight load requests per peer * - FIFO order for pending requests * - O(1) enqueue and dequeue operations using LinkedList * - Manages timeouts for in-flight loads with a single timer */ export declare class OutgoingLoadQueue { private peerId; private inFlightLoads; private inFlightCounter; private highPriorityPending; private lowPriorityPending; /** * Tracks nodes in the low-priority queue by CoValue ID for O(1) upgrade lookup. */ private lowPriorityNodes; /** * Tracks nodes in the high-priority queue by CoValue ID for O(1) immediate mode lookup. */ private highPriorityNodes; private timeoutHandle; constructor(peerId: PeerID); /** * Check if we can send another load request. */ private canSend; /** * Track that a load request has been sent. */ private trackSent; private untrackInFlight; /** * Schedule a timeout check if not already scheduled. * Uses a single timer to check all in-flight loads. */ private scheduleTimeoutCheck; /** * Check all in-flight loads for timeouts and handle them. */ private checkTimeouts; trackUpdate(coValue: CoValueCore): void; /** * Track that a load request has completed. * Triggers processing of pending requests. */ trackComplete(coValue: CoValueCore, source?: LoadCompletionSource): void; /** * Enqueue a load request. * Immediately processes the queue to send requests if capacity is available. * Skips CoValues that are already in-flight or pending. * * @param coValue - The CoValue to load * @param sendCallback - Callback to send the request when ready * @param mode - Optional mode: "low-priority" for background loads, "immediate" to bypass queue */ enqueue(value: CoValueCore, sendCallback: () => void, mode?: LoadMode): void; private processing; /** * Process all pending load requests while capacity is available. * High-priority requests are processed first, then low-priority. */ private processQueue; /** * Clear all state. Called on disconnect. * Clears the timeout and all pending/in-flight loads. */ clear(): void; /** * Get the number of in-flight loads (for testing/debugging). */ get inFlightCount(): number; /** * Get the number of pending loads (for testing/debugging). */ get pendingCount(): number; /** * Get the number of high-priority pending loads (for testing/debugging). */ get highPriorityPendingCount(): number; /** * Get the number of low-priority pending loads (for testing/debugging). */ get lowPriorityPendingCount(): number; } //# sourceMappingURL=OutgoingLoadQueue.d.ts.map