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

Make registry fully thread safe #80

Merged
merged 2 commits into from
Nov 23, 2022
Merged

Conversation

mensfeld
Copy link
Contributor

Without this change potential incrementation can "go away" and can actually mismatch by 1 if run in multiple threads the same time. This can lead to super weird errors where counter is not as expected (been there, took me ages to debug).

ref: ruby-concurrency/concurrent-ruby#970

Without this change potential incrementation can "go away" and can actually mismatch by 1 if run in multiple threads the same time. This can lead to super weird errors where counter is not as expected (been there, took me ages to debug).

ref: ruby-concurrency/concurrent-ruby#970
@flash-gordon flash-gordon merged commit 9247042 into rom-rb:main Nov 23, 2022
@granthusbands
Copy link

Concurrent::Map already has the necessary machinery, so using a new mutex means you now have two separate locks for one piece of data. You should use something like:

registery.compute(key) { |v| v+1 }

@flash-gordon
Copy link
Member

@granthusbands thanks for the heads up

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.

3 participants