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

Async loading of bundles work with configurable string fetcher. #1

Merged
merged 2 commits into from
Oct 27, 2020

Conversation

djg
Copy link
Collaborator

@djg djg commented Oct 19, 2020

No description provided.

src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/registry/asynchronous.rs Outdated Show resolved Hide resolved
src/registry/asynchronous.rs Show resolved Hide resolved
src/registry/mod.rs Outdated Show resolved Hide resolved
src/source.rs Outdated Show resolved Hide resolved
src/source.rs Outdated
Missing => None,
Loaded(res) => Some(res),
Loading(..) => {
panic!("[l10nregistry] Attempting to synchronously load file {} while it's being loaded asynchronously.", &full_path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we here debug_print and drop the async load, and replace it with a sync load?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could perform a sync load and not update the cache? I wasn't sure which was the best approach.

I wanted to be able to replace the loading state with loaded and fire the value to the waiting futures, but I'm not sure how to do that. A potential solution would be to store a oneshot::Sender and Shared<oneshot::Receiver>. The async loading future could then check that the state is still loading, and if so, send the result. The sync loading could do the same.

It's a little more complicated and I just wanted to get the system working. Could be leave this and open a issue to implement a more desirable behavior?

src/source.rs Outdated Show resolved Hide resolved
src/source.rs Show resolved Hide resolved
tests/registry.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@djg djg force-pushed the l10n-async-support branch 2 times, most recently from 670ed00 to 07f4583 Compare October 26, 2020 02:01
@zbraniecki zbraniecki merged commit 9afa4f5 into mozilla:master Oct 27, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants