Closed mensfeld closed 1 year ago
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 }
@granthusbands thanks for the heads up
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: https://github.com/ruby-concurrency/concurrent-ruby/issues/970