Add System.Collections.Concurrent.ConcurrentHashSet<T> #15326
Labels
api-needs-work
API needs work before it is approved, it is NOT ready for implementation
area-System.Collections
Milestone
We already have classes in the
System.Collections.Concurrent
namespace that provide (mostly) equivalent APIs to most of those in theSystem.Collections.Generic
namespace. However, one omission is a concurrent equivalent forSystem.Collections.Generic.HashSet<T>
. At the moment, if a thread-safe hash set is needed, we are left with one of three options:System.Collections.Generic.HashSet<T>
in a wrapper class.System.Collections.Concurrent.ConcurrentDictionary<TKey, TValue>
with "dummy" values such asobject
orbyte
, 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...).The text was updated successfully, but these errors were encountered: