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

thread safe set implementation #666

Merged
merged 3 commits into from Feb 24, 2018
Merged

Conversation

haridutt12
Copy link
Contributor

No description provided.

@haridutt12
Copy link
Contributor Author

This is thread safe set implementation along the lines of thread safe Array
fixes #564

@haridutt12
Copy link
Contributor Author

haridutt12 commented Jul 21, 2017

@pitr-ch please review this as this is my first open source contribution.

@pitr-ch pitr-ch added this to the 1.2.0 milestone Jul 24, 2017
@pitr-ch pitr-ch added the enhancement Adding features, adding tests, improving documentation. label Jul 24, 2017
@pitr-ch
Copy link
Member

pitr-ch commented Jul 24, 2017

Thank you for your contribution! At first glance it looks good, however I'll have to return to it and give it more thought. Maybe @thedarkone could help. @thedarkone would you have time to help with the review?

Copy link
Contributor

@thedarkone thedarkone left a comment

Choose a reason for hiding this comment

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

Please remove lib/concurrent/extension.so from the commit.

Otherwise this looks OK.

it 'concurrency' do
(1..THREADS).map do |i|
Thread.new do
set << i
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this whole spec to look like Hash spec:

(by adding another inner 1000.times do |j| loop, just like for Hash).

@haridutt12
Copy link
Contributor Author

haridutt12 commented Aug 1, 2017

@thedarkone, @pitr-ch can u please review the changes..

# `Concurrent::Set`. It reads Set `a`, then it creates new `Concurrent::Set`
# which is concatenation of `a` and `b`, then it writes the concatenation to `a`.
# The read and write are independent operations they do not form a single atomic
# operation therefore when two `+=` operations are executed concurrently updates
Copy link
Collaborator

@eregon eregon Aug 18, 2017

Choose a reason for hiding this comment

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

Unfinished sentence: updates ... may be lost. Use #merge instead.
From

# may be lost. Use `#concat` instead.

Thread.new do
1000.times do |j|
set << i
set.empty?
Copy link
Contributor

Choose a reason for hiding this comment

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

This spec does not make set any expectations. Can you clarify what you are testing and make expectations about the behavior in the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ianks actually this is my first ever contribution so i dont have much knowledge about minitests so can u plese help me out in this?

Copy link
Member

Choose a reason for hiding this comment

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

Actually the tests follow what we have for Array and Hash. I'll improve all of them at least a bit.

@pitr-ch
Copy link
Member

pitr-ch commented Dec 3, 2017

@thedarkone @ianks @eregon Thanks you for helping with the review!

@pitr-ch pitr-ch dismissed thedarkone’s stale review February 21, 2018 13:13

Requested changes fixed.

@pitr-ch
Copy link
Member

pitr-ch commented Feb 21, 2018

I've improved the tests a bit, updated documentation, squashed and rebased. After CI passes it can be merged.

@pitr-ch pitr-ch merged commit 50ed4a5 into ruby-concurrency:master Feb 24, 2018
@ghost ghost removed the in progress label Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding features, adding tests, improving documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants