You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We already have classes in the System.Collections.Concurrent namespace that provide (mostly) equivalent APIs to most of those in the System.Collections.Generic namespace. However, one omission is a concurrent equivalent for System.Collections.Generic.HashSet<T>. At the moment, if a thread-safe hash set is needed, we are left with one of three options:
Creating a thread-safe collection class from scratch.
Synchronizing System.Collections.Generic.HashSet<T> in a wrapper class.
Using System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue> with "dummy" values such as object or byte, either directly or through a wrapper.
None of these approaches is ideal. The first and second option are both error prone (concurrency is hard) and difficult to fully optimize. The third wastes memory and time spent allocating the dummy objects. It seems reasonable to expect such a class wouldn't be too challenging to create given that it would appear to mostly consist of reducing the functionality in the already-existing ConcurrentDictionary<TKey, TValue> class (though that one is ~2,000 line long, so...).
Activity
joshfree commentedon Oct 1, 2015
/cc @terrajobst
daveaglick commentedon Oct 1, 2015
BTW - if this class is deemed appropriate, I certainly don't mind doing the initial legwork.
redknightlois commentedon Oct 13, 2015
I just had to use this (http://pastebin.com/8REHRFFL) minutes ago. @daveaglick beat me to report it. :P
daveaglick commentedon Jul 14, 2016
FYI, for anyone stumbling on this issue - @i3arnon has an implementation here: https://github.com/i3arnon/ConcurrentHashSet (https://www.nuget.org/packages/ConcurrentHashSet/)
karelz commentedon Sep 26, 2016
Dupe of dotnet/corefx#6318