@newdash/newdash
Version:
javascript/typescript utility library
45 lines (44 loc) • 960 B
TypeScript
/**
*
* queue pending size out of limit
*
* @internal
* @private
* @ignore
*/
export declare class QueueOverFlowError extends Error {
}
/**
* BlockedQueue
*
* a blocked queue for async operations
*
* @since 5.19.0
* @category Functional
*/
export declare class BlockedQueue<I = any> {
private _capacity;
private _notifyQueue;
private _maxPending;
private _container;
/**
* @param capacity default 1000
* @param maxPending default 10 * capacity, the max allowed number of pending items
*/
constructor(capacity?: number, maxPending?: number);
/**
* push an item to the queue, blocked when the queue is full
*
* @throws {QueueOverFlowError} throw when pending items are too much
* @param item
* @returns
*/
enQueue(item: I): Promise<void>;
/**
* retrieve an item from queue
*
* @returns
*/
deQueue(): Promise<I>;
}
export default BlockedQueue;