()
| 20 | } |
| 21 | |
| 22 | async pop(): Promise<T> { |
| 23 | if (this.#elements.length > 0) { |
| 24 | return this.#elements.pop()!; |
| 25 | } |
| 26 | |
| 27 | if (this.#size < this.#max_size && this.#creator) { |
| 28 | this.#size++; |
| 29 | return await this.#creator(); |
| 30 | } |
| 31 | const d = Promise.withResolvers<T>(); |
| 32 | this.#queue.push(d); |
| 33 | return await d.promise; |
| 34 | } |
| 35 | |
| 36 | push(value: T): void { |
| 37 | if (this.#queue.length > 0) { |