UNPKG

@yume-chan/scrcpy-decoder-webcodecs

Version:

Raw H.264 stream decoder and renderer using WebCodecs API (requires modern browser).

30 lines 793 B
export class Pool { #controller; #readable = new ReadableStream({ start: (controller) => { this.#controller = controller; }, pull: (controller) => { controller.enqueue(this.#initializer()); }, }, { highWaterMark: 0 }); #reader = this.#readable.getReader(); #initializer; #size = 0; #capacity; constructor(initializer, capacity) { this.#initializer = initializer; this.#capacity = capacity; } async borrow() { const result = await this.#reader.read(); return result.value; } return(value) { if (this.#size < this.#capacity) { this.#controller.enqueue(value); this.#size += 1; } } } //# sourceMappingURL=pool.js.map