Skip to content

Refactor snapshot cache initialization to better support nnbd #2761

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

Merged
merged 1 commit into from
Aug 24, 2021

Conversation

jcollins-g
Copy link
Contributor

No description provided.

@google-cla google-cla bot added the cla: yes Google CLA check succeeded. label Aug 23, 2021
@jcollins-g jcollins-g requested a review from srawlins August 23, 2021 23:05
Copy link
Member

@srawlins srawlins left a comment

Choose a reason for hiding this comment

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

Very nice

/// function must be called before process exit to clean up snapshots in the
/// cache.
class SnapshotCache {
static SnapshotCache _instance;
static final _instances = <ResourceProvider, SnapshotCache>{};
Copy link
Member

Choose a reason for hiding this comment

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

Gnerally exactly one key/value pair in any given execution, yeah? Maybe like... two, for a test execution that uses mocks and real test packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The cache pretended before that there was only ever one, but I was suspicious of how it handled mocks or other inputs by ignoring them after the first call to createInstance if you hadn't dispose()d of them. That seemed like a bad idea in an asynchronous program, and was a pain to migrate without a refactor.

@jcollins-g jcollins-g merged commit 462fce2 into dart-lang:master Aug 24, 2021
@jcollins-g jcollins-g deleted the nnbd-prep-tools branch August 24, 2021 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants