Specify what `Transferable` objects are
JordanMartinez opened this issue · 4 comments
JordanMartinez commented
Description
Replace Transferable opaque type with type class based on: https://html.spec.whatwg.org/multipage/structured-data.html#transferable-objects
gbagan commented
A related issue is that ArrayBuffer are transferable and a transfer sets the byteLength to 0.
Thus the signature of byteLength must be
byteLength :: ArrayBuffer -> Effect ByteLengthJordanMartinez commented
A related issue is that ArrayBuffer are transferable and a transfer sets the byteLength to 0.
Where does the spec say that?
gbagan commented
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects
In the first example:
// Create an 8MB "file" and fill it. 8MB = 1024 * 1024 * 8 B
const uInt8Array = new Uint8Array(1024 * 1024 * 8).map((v, i) => i);
console.log(uInt8Array.byteLength); // 8388608
// Transfer the underlying buffer to a worker
worker.postMessage(uInt8Array, [uInt8Array.buffer]);
console.log(uInt8Array.byteLength); // 0The example is for uInt8Array but it is also true for ArrayBuffer.
JordanMartinez commented
😭
Well that throws a wrench into things...