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

Evaluate improved sync-load-during-async-load strategy #15

Open
zbraniecki opened this issue Aug 2, 2021 · 1 comment
Open

Evaluate improved sync-load-during-async-load strategy #15

zbraniecki opened this issue Aug 2, 2021 · 1 comment

Comments

@zbraniecki
Copy link
Contributor

As per bug https://bugzilla.mozilla.org/show_bug.cgi?id=1723191 we have scenarios where a sync load is triggered in the middle of an async load and we should consider options for handling such scenario better than with https://github.com/mozilla/l10nregistry-rs/blob/master/src/source/mod.rs#L239-L255

With that approach, we just load the one-off synchronously and return it, while we also complete async and we only will cache the async.

Maybe we could hook into the async load, discard it, supply data from the sync load and cache that?

@zbraniecki
Copy link
Contributor Author

I started looking into this, and the trick here seems to be - how do we cancel an ongoing future in https://github.com/mozilla/l10nregistry-rs/blob/master/src/source/fetcher.rs#L28

We'd like to be able to "drop" a future, and replace it with ResourceStatus resolved in https://github.com/mozilla/l10nregistry-rs/blob/master/src/source/mod.rs#L254 and then "inject" our synchronously loaded data into https://github.com/mozilla/l10nregistry-rs/blob/master/src/source/mod.rs#L24 and resolve it.

Two questions:

  1. Would Drop be enough here or do we need to somehow specially cancel a future?
  2. Is there a way to "force-resolve" a pending Shared Future from outside?

@emilio - do you have any pointers for me here?

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

No branches or pull requests

1 participant