- From: Domenic Denicola <notifications@github.com>
- Date: Tue, 24 Feb 2015 08:41:55 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Message-ID: <whatwg/streams/pull/288/c75792719@github.com>
OK so. - `rbs.readInto(ab, offset, size)` will use `ArrayBuffer.transfer` to create a new array buffer, `rbsAB`, whose contents are transferred from `ab`. Thus `ab` is detached. Eventually the returned promise is fulfilled with `ab2` (instead of bytesRead). That is pretty nice! Except for the issue mentioned in https://github.com/whatwg/streams/issues/253#issuecomment-75790533. - `const p1 = rbs.readInto(ab, size); const reader = rbs.getReader(); const p2 = reader.readInto(ab2, size2)` will use `ArrayBuffer.transfer` to create a new array buffer, `rbsAB`, whose contents are transferred from `ab`. `ab` is now detached. Eventually the read finishes and `rbsAB` has bytes in it. Then, under 1, `p1` is rejected, whereas under 3, it remains pending. In both cases, do we fulfill `p2` with `rbsAB`? Do we just ignore `ab2`? Hmm. Now that we have this detaching-returning-different-buffers thing, maybe async readInto is not the right model, and feedArrayBuffer or setAllocator would make more sense. It feels weird to supply an argument to `readInto` whose backing memory is used, while the actual array buffer in question gets detached and is no longer useful. Even if we changed the name (`readInto` no longer makes sense, but e.g. `readBytes` is fine) it's still an awkward API. --- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/pull/288#issuecomment-75792719
Received on Tuesday, 24 February 2015 16:42:24 UTC