[whatwg/streams] Returning buffers to the underlying source (Issue #1217)

An alternative or perhaps a companion to BYOB readers is the concept of a "two-phase" read where the `UnderlyingSource` enqueues a chunk but can get a later signal that the buffer holding that chunk is no longer in use and so can be reused for another chunk.

This could be useful, for example, when the data source being wrapped by the `UnderlyingSource` provides a BYOB-style API and the buffers passed as chunks to `enqueue()` could eventually be reused once they have been returned to the source.

It could also be useful for sources implemented by the platform which read data from shared memory, as an `ArrayBuffer` could be constructed over this shared memory and enqueued instead of requiring a copy of the data to be made (BYOB only saves the buffer allocation, not the copy). In this case, since shared memory is a limited resource, failure to return the chunks to the stream could result in backpressure. In the most extreme case the source may only allow a single buffer to be outstanding before later reads could complete.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1217
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1217@github.com>

Received on Thursday, 10 February 2022 00:29:32 UTC