UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

38 lines 1.41 kB
import { JobQueueOpts, QueueMetrics } from "./options.js"; /** * JobQueue that stores arguments in the job array instead of closures. * Supports a single itemProcessor, for arbitrary functions use the JobFnQueue */ export declare class JobItemQueue<Args extends any[], R> { private readonly itemProcessor; private readonly opts; /** * We choose to use LinkedList instead of regular array to improve shift() / push() / pop() performance. * See the LinkedList benchmark for more details. * */ private readonly jobs; private readonly metrics?; private runningJobs; private lastYield; /** Resolvers waiting for space in the queue */ private spaceWaiters; constructor(itemProcessor: (...args: Args) => Promise<R>, opts: JobQueueOpts, metrics?: QueueMetrics); get jobLen(): number; push(...args: Args): Promise<R>; /** * Returns a promise that resolves when there is space in the queue. * If the queue already has space, resolves immediately (noop). * Use this to apply backpressure when the caller should wait rather than * have push() throw QUEUE_MAX_LENGTH. */ waitForSpace(): Promise<void>; getItems(): { args: Args; addedTimeMs: number; }[]; dropAllJobs: () => void; private runJob; private notifySpaceWaiters; private abortAllJobs; } //# sourceMappingURL=itemQueue.d.ts.map