Skip to content

Simplify ProviderCache and make it instantiable since it is intentionally not thread safe #3312

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 2 commits into from
Sep 25, 2019

Conversation

jnm2
Copy link
Contributor

@jnm2 jnm2 commented Jul 7, 2019

I saw this file in passing in a previous refactoring and noticed the possibilities in the PR title.

Commit 1: CacheEntry would make sense as a dictionary key if it took provider arguments into account. Since it doesn't, it's a "just in case we ever do this" construct which complicates the source code. It also has a marginal negative influence on dictionary performance by not being a struct and by not implementing IEquatable<>. I figured we could wait until we need it rather than adding even more code it.

Commit 2: static mutable things are good to avoid in general but especially when the mutations are not thread safe because you take away all control from the client code to isolate it to a single thread. Now, it's the responsibility of the code that instantiates it to not share the instance somewhere that could be accessed from another thread.

@jnm2 jnm2 added this to the 3.13 milestone Jul 7, 2019
@jnm2 jnm2 requested a review from a team July 7, 2019 02:46
Copy link
Member

@rprouse rprouse left a comment

Choose a reason for hiding this comment

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

LGTM. It took me a bit to see how it was accessed until I realized the static property has the same name as the class 😄

@rprouse rprouse merged commit bd45c2e into nunit:master Sep 25, 2019
@jnm2 jnm2 deleted the refactor_provider_cache branch September 25, 2019 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants