Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate use of futures/stream/async in Fetch #22813

Open
gterzian opened this issue Feb 3, 2019 · 0 comments
Open

Investigate use of futures/stream/async in Fetch #22813

gterzian opened this issue Feb 3, 2019 · 0 comments
Labels

Comments

@gterzian
Copy link
Member

@gterzian gterzian commented Feb 3, 2019

A "fetch" currently looks like:

  1. Spawn a thread to run fetch.
  2. Ask the cache for a cached response
  3. If the cached returned a cached, yet still ongoing response, wait for the cached response to finish.
  4. If the cache couldn't construct a response, do a [network fetch](
    fn http_network_fetch(
    .
  5. Wait for the network fetch to complete.

Note that the network fetch already uses a Tokio runtime to obtain the response and then handle the response.

In all cases where either the network or cached response is "awaited", this DoneChannel is used to signal that the response is ready, or cancelled.

It appears to me that the thread spawned at 1 above could be replaced with a(or several) Future, or maybe Stream, and that the entire workflow could be modeled with it. The "done channel" could also be replaced with a task-aware channel.

This is probably a better solution to the problem of "one thread per fetch" noted here #22768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.