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

4.x: Fix PriorityQueue to not share a item ordering helper index #507

Merged
merged 1 commit into from May 26, 2018

Conversation

akarnokd
Copy link
Collaborator

The PriorityQueue._count field was a static field shared between all instances the PriorityQueue of the same type argument. I can only assume this was thought as a tradeoff between having 8 more bytes per priority queue or trashing everybody else's cache who happen to be prioritizing on the same type argument.

This PR simply changes it to a per instance counter and also removes the Interlocked.Increment as the class itself is by no means thread-safe so it makes no sense to have the creation of a fresh index atomic in Enqueue.

@clairernovotny clairernovotny merged commit 206f770 into dotnet:master May 26, 2018
@akarnokd akarnokd deleted the PriorityQueueFix branch May 26, 2018 14:55
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