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

Fix Map#each and #each_pair not returning enumerator outside of MRI #644

Merged
merged 2 commits into from Apr 2, 2017
Merged

Fix Map#each and #each_pair not returning enumerator outside of MRI #644

merged 2 commits into from Apr 2, 2017

Conversation

ivoanjo
Copy link
Contributor

@ivoanjo ivoanjo commented Mar 29, 2017

When no block was passed to Map#each_pair or its alias Map#each, the NonConcurrentMapBackend would return an enumerator, which would allow enumerable methods to be used on a Map.

But the alternate Map backends, JRubyMapBackend and AtomicReferenceMapBackend did not implement the same logic.

As a fix, let's move the logic down to the shared Map class, so all implementations can use it.

Fixes #643

The SynchronizedMapBackend, by definition, uses a lock around every
operation, and thus could never pass a test that checks that updates
and reads can happen concurrently.
When no block was passed to Map#each_pair or its alias Map#each, the
NonConcurrentMapBackend would return an enumerator, which would allow
enumerable methods to be used on a Map.

But the alternate Map backends, JRubyMapBackend and
AtomicReferenceMapBackend did not implement the same logic.

As a fix, let's move the logic down to the shared Map class, so all
implementations can use it.

Fixes #643
Copy link
Member

@pitr-ch pitr-ch left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! It helps a lot.

@pitr-ch pitr-ch merged commit 8912af0 into ruby-concurrency:master Apr 2, 2017
@ivoanjo
Copy link
Contributor Author

ivoanjo commented Dec 2, 2017

Hey @pitr-ch any chance this can get released? I just got bitten by it again (and it's been so long I didn't even remember I had already fixed it 😭). 😀

@pitr-ch
Copy link
Member

pitr-ch commented Dec 3, 2017

Sorry, I am catching up on c-r after busy summer, I'll get a release out.

@ivoanjo
Copy link
Contributor Author

ivoanjo commented Dec 3, 2017

Great, thanks! 👍 👍 👍

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.

Concurrent::Map#each behaves differently in MRI and JRuby
2 participants