Re: [whatwg/fetch] Use tasks to manipulate streams (#1270)

@domenic commented on this pull request.

Is the stream created in parallel? It's created in the first portion of HTTP-network fetch, but maybe HTTP-network fetch itself was called in parallel?

Another architecture which you could explore is to do everything in the main thread except for the "wait for bytes or finished signal from the network" step, and then queue a task whenever you get bytes (regardless of whether it's bytes or a finished signal). I.e., spend the minimum amount of time possible in parallel.

>  
-         <li><p>If <var>stream</var> is <a for=ReadableStream>errored</a>, then
-         <a lt=terminated for=fetch>terminate</a> the ongoing fetch.
+          <ol>
+           <li><p><a for=ReadableStream>Enqueue</a> a {{Uint8Array}} wrapping an {{ArrayBuffer}}
+           containing <var>bytes</var> into <var>stream</var>.

FWIW this can be made rigorous these days with https://heycam.github.io/webidl/#arraybufferview-create (`[=ArrayBufferView/new=] {{Uint8Array}} given |bytes| in some realm`).

>  
-         <li><p>If <var>stream</var> doesn't <a for=ReadableStream>need more data</a> ask the user
-         agent to <a for=fetch>suspend</a> the ongoing fetch.
+           <li><p>If <var>stream</var> is <a for=ReadableStream>errored</a>, then
+           <a lt=terminated for=fetch>terminate</a> the ongoing fetch.
+
+           <li><p>If <var>stream</var> doesn't <a for=ReadableStream>need more data</a> ask the user
+           agent to <a for=fetch>suspend</a> the ongoing fetch.
+          </ol>
+
+         <li><p>Otherwise, if the bytes transmission for <var>response</var>'s message body is done
+         normally and <var>stream</var> is <a for=ReadableStream>readable</a>, then
+         <a for=ReadableStream>close</a> <var>stream</var>, <a for=/>finalize response</a> for
+         <var>fetchParams</var> and <var>response</var>.

Closing should also be done in a task right?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1270#pullrequestreview-713043258

Received on Thursday, 22 July 2021 17:22:15 UTC