/*! Copyright 2019 Ron Buckton Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. THIRD PARTY LICENSE NOTICE: AsyncQueue is derived from the implementation of Queue in Promise Extensions for Javascript: https://github.com/rbuckton/prex Promise Extensions is licensed under the Apache 2.0 License: Promise Extensions for JavaScript Copyright (c) Microsoft Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import { Cancelable } from "@esfx/cancelable"; /** * An asynchronous queue. */ export declare class AsyncQueue { private _state; private _available; private _pending; /** * Initializes a new instance of the AsyncQueue class. * * @param iterable An optional iterable of values or promises. */ constructor(iterable?: Iterable>); /** * Gets a value indicating whether new items can be added to the queue. */ get writable(): boolean; /** * Gets a value indicating whether items can be read from the queue. */ get readable(): boolean; /** * Gets a value indicating whether the queue has ended and there are no more items available. */ get done(): boolean; /** * Gets the number of entries in the queue. * When positive, indicates the number of entries available to get. * When negative, indicates the number of requests waiting to be fulfilled. */ get size(): number; /** * Removes and returns a `Promise` for the first value in the queue. If the queue is empty, * returns a `Promise` for the next value to be added to the queue. * * @param cancelable A `Cancelable` used to cancel the request. */ get(cancelable?: Cancelable): Promise; /** * Adds a value to the end of the queue. If the queue is empty but has a pending * dequeue request, the value will be dequeued and the request fulfilled. */ put(this: AsyncQueue): void; /** * Adds a value to the end of the queue. If the queue is empty but has a pending * dequeue request, the value will be dequeued and the request fulfilled. * @param value A value or promise to add to the queue. */ put(value: T | PromiseLike): void; /** * Blocks attempts to read from the queue until it is empty. Available items in the queue * can still be read until the queue is empty. */ doneReading(): void; /** * Blocks attempts to write to the queue. Pending requests in the queue can still be * resolved until the queue is empty. */ doneWriting(): void; /** * Blocks future attempts to read or write from the queue. Available items in the queue * can still be read until the queue is empty. Pending reads from the queue are rejected * with a `CancelError`. */ end(): void; } //# sourceMappingURL=index.d.ts.map