-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
What about adding a ConcurrentSet<T>? #16443
Comments
What does this gives you that ConcurrentDictionary<T, object> (and just not using the value) ? |
Nothing but communicates intent better imo. I usually do stuff like this (not a proper set). |
@ayende Apart from the "it's clearer what this code does" reason and the precedent of having A very simple test: when I add a million values to I assume the difference with concurrent collections would be similar. |
If anything more so, since the concurrency consideration means there are a few spots that want to be particularly efficient, so not having to do anything with values would be an even greater gain there than with |
I think a |
I know of one C# concurrent hash set and one in Java and neither offer concurrency on set operations, only on the add, remove, contains. |
Is there's plan to add this? If there is and it's up for grabs, I can look into it |
@hermitdave You might want to have a look at how the API review process works. |
Thanks @svick will keep an eye on this one |
Agreed, perhaps it should not be called |
@hermitdave Do you have a proposal for this ? |
@Priya91 oops forgot about this one.. I'll get started asap |
Starting work on this |
@hermitdave are you working on it? |
@hermitdave do you still have interest in writing up the formal proposal here? If we review okays it promply and someone is interested in implementation, there may still be time to get this into 2.0. Possibly the implementation could begin by wrapping ConcurrentDictionary, so the API is quickly available to use, then rewritten to have the space/time improvements of a custom implementation. |
FWIW, @i3arnon has a really nice implementation at https://github.com/i3arnon/ConcurrentHashSet |
@i3arnon maybe you should do a PR instead. |
Just to be clear folks -- feel free to make a PR, but we can't take any change without an API review approval. That needs a proposal written up as above. @hermitdave were you going to do that? |
@danmosemsft I had a look at what @i3arnon did and it is which is decent. if he isn't interested then I will do a PR later this week |
@hermitdave we first need API proposal (see API review process) - i.e. review the API surface of the collection (with motivation and relation to 'classic' HashSet and other concurrent collections). Just to set expectations: Based on recent discussions around other collections, we will likely have to find the right place for new collections (CoreFX repo might not be the desired destination). That may take even longer. |
@hermitdave apologies, I wasn't clear in my comment. I should have said -- feel free to prototype in a fork, but a PR against CoreFX would be noise at this point without API approval |
Just FYI The implementation Dan refers to above is very specialized (e.g. there is no remove), and is probably not representative. The C# compiler community wrote a simple wrapper for themselves, that is probably a better representation of what would be done if we wanted to add this class. http://source.roslyn.io/#microsoft.codeanalysis/InternalUtilities/ConcurrentSet.cs |
I find myself wanting this very much on occasion. Seems like something that shouldn't be overlooked. |
@vancem I can't agree more! But three years passed, and no ConcurrentHashSet yet =.= |
This comment has been minimized.
This comment has been minimized.
@reggaeguitar fixed the link. |
And which allows to remove a specific element, instead of just a random one (I just needed this today, and see https://stackoverflow.com/questions/3029818/how-to-remove-a-single-specific-object-from-a-concurrentbag for another example). |
So no one ever made an API proposal for this? Maybe you guys should add the |
Duplicate of #39919 that has actual API proposal |
The need for it comes up every now and then. To me it would make sense next to
ConcurrentDictionary<TKey, TValue>
The text was updated successfully, but these errors were encountered: